sbuild  1.7.1
i18n.h
Go to the documentation of this file.
1 /* Copyright © 2005-2013 Roger Leigh <rleigh@debian.org>
2  *
3  * schroot is free software: you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * schroot is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  *********************************************************************/
18 
24 #ifndef SBUILD_I18N_H
25 #define SBUILD_I18N_H
26 
27 #include <sbuild/config.h>
28 
29 #include <string>
30 
31 #ifdef SBUILD_FEATURE_NLS
32 # include <libintl.h>
33 #endif // SBUILD_FEATURE_NLS
34 
35 // Undefine macros which would interfere with our functions.
36 #ifdef gettext
37 #undef gettext
38 #endif
39 #ifdef _
40 #undef _
41 #endif
42 #ifdef gettext_noop
43 #undef gettext_noop
44 #endif
45 #ifdef N_
46 #undef N_
47 #endif
48 
49 namespace sbuild
50 {
57  inline const char *
58  gettext (const char *message)
59  {
60 #ifdef SBUILD_FEATURE_NLS
61  return dgettext (SBUILD_MESSAGE_CATALOGUE, message);
62 #else
63  return message;
64 #endif // SBUILD_FEATURE_NLS
65  }
66 
73  inline const char *
74  gettext (const std::string& message)
75  {
76  return gettext(message.c_str());
77  }
78 
86  inline const char *
87  _ (const char *message)
88  {
89  return gettext (message);
90  }
91 
98  inline const char *
99  gettext_noop (const char *message)
100  {
101  return message;
102  }
103 
111  inline const char *
112  N_ (const char *message)
113  {
114  return gettext_noop (message);
115  }
116 
117 }
118 
119 #endif /* SBUILD_I18N_H */
120 
121 /*
122  * Local Variables:
123  * mode:C++
124  * End:
125  */