1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = glib-I18N.html
27  * outPack = glib
28  * outFile = Internationalization
29  * strct   = 
30  * realStrct=
31  * ctorStrct=
32  * clss    = Internationalization
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * structWrap:
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module glib.Internationalization;
54 
55 public  import gtkc.glibtypes;
56 
57 private import gtkc.glib;
58 private import glib.ConstructionException;
59 
60 private import glib.Str;
61 
62 
63 
64 /**
65  * GLib doesn't force any particular localization method upon its users.
66  * But since GLib itself is localized using the gettext() mechanism, it seems
67  * natural to offer the de-facto standard gettext() support macros in an
68  * easy-to-use form.
69  *
70  * In order to use these macros in an application, you must include
71  * glib/gi18n.h. For use in a library, you must include
72  * glib/gi18n-lib.h after defining
73  * the GETTEXT_PACKAGE macro suitably for your library:
74  *
75  * $(DDOC_COMMENT example)
76  *
77  * For an application, note that you also have to call bindtextdomain(),
78  * bind_textdomain_codeset(), textdomain() and setlocale() early on in your
79  * main() to make gettext() work.
80  *
81  * For a library, you only have to call bindtextdomain() and
82  * bind_textdomain_codeset() in your initialization function. If your library
83  * doesn't have an initialization function, you can call the functions before
84  * the first translated message.
85  *
86  * The gettext manual covers details of how to set up message extraction
87  * with xgettext.
88  */
89 public class Internationalization
90 {
91 	
92 	/**
93 	 */
94 	
95 	/**
96 	 * This function is a wrapper of dgettext() which does not translate
97 	 * the message if the default domain as set with textdomain() has no
98 	 * translations for the current locale.
99 	 * The advantage of using this function over dgettext() proper is that
100 	 * libraries using this function (like GTK+) will not use translations
101 	 * if the application using the library does not have translations for
102 	 * the current locale. This results in a consistent English-only
103 	 * interface instead of one having partial translations. For this
104 	 * feature to work, the call to textdomain() and setlocale() should
105 	 * precede any g_dgettext() invocations. For GTK+, it means calling
106 	 * textdomain() before gtk_init or its variants.
107 	 * This function disables translations if and only if upon its first
108 	 * Since 2.18
109 	 * Params:
110 	 * domain = the translation domain to use, or NULL to use
111 	 * the domain set with textdomain(). [allow-none]
112 	 * msgid = message to translate
113 	 * Returns: The translated string
114 	 */
115 	public static string dgettext(string domain, string msgid)
116 	{
117 		// const gchar * g_dgettext (const gchar *domain,  const gchar *msgid);
118 		return Str.toString(g_dgettext(Str.toStringz(domain), Str.toStringz(msgid)));
119 	}
120 	
121 	/**
122 	 * This is a variant of g_dgettext() that allows specifying a locale
123 	 * category instead of always using LC_MESSAGES. See g_dgettext() for
124 	 * more information about how this functions differs from calling
125 	 * dcgettext() directly.
126 	 * Since 2.26
127 	 * Params:
128 	 * domain = the translation domain to use, or NULL to use
129 	 * the domain set with textdomain(). [allow-none]
130 	 * msgid = message to translate
131 	 * category = a locale category
132 	 * Returns: the translated string for the given locale category
133 	 */
134 	public static string dcgettext(string domain, string msgid, int category)
135 	{
136 		// const gchar * g_dcgettext (const gchar *domain,  const gchar *msgid,  gint category);
137 		return Str.toString(g_dcgettext(Str.toStringz(domain), Str.toStringz(msgid), category));
138 	}
139 	
140 	/**
141 	 * This function is a wrapper of dngettext() which does not translate
142 	 * the message if the default domain as set with textdomain() has no
143 	 * translations for the current locale.
144 	 * See g_dgettext() for details of how this differs from dngettext()
145 	 * proper.
146 	 * Since 2.18
147 	 * Params:
148 	 * domain = the translation domain to use, or NULL to use
149 	 * the domain set with textdomain(). [allow-none]
150 	 * msgid = message to translate
151 	 * msgidPlural = plural form of the message
152 	 * n = the quantity for which translation is needed
153 	 * Returns: The translated string
154 	 */
155 	public static string dngettext(string domain, string msgid, string msgidPlural, gulong n)
156 	{
157 		// const gchar * g_dngettext (const gchar *domain,  const gchar *msgid,  const gchar *msgid_plural,  gulong n);
158 		return Str.toString(g_dngettext(Str.toStringz(domain), Str.toStringz(msgid), Str.toStringz(msgidPlural), n));
159 	}
160 	
161 	/**
162 	 * This function is a variant of g_dgettext() which supports
163 	 * a disambiguating message context. GNU gettext uses the
164 	 * '\004' character to separate the message context and
165 	 * message id in msgctxtid.
166 	 * If 0 is passed as msgidoffset, this function will fall back to
167 	 * trying to use the deprecated convention of using "|" as a separation
168 	 * character.
169 	 * This uses g_dgettext() internally. See that functions for differences
170 	 * with dgettext() proper.
171 	 * Applications should normally not use this function directly,
172 	 * but use the C_() macro for translations with context.
173 	 * Since 2.16
174 	 * Params:
175 	 * domain = the translation domain to use, or NULL to use
176 	 * the domain set with textdomain(). [allow-none]
177 	 * msgctxtid = a combined message context and message id, separated
178 	 * by a \004 character
179 	 * msgidoffset = the offset of the message id in msgctxid
180 	 * Returns: The translated string
181 	 */
182 	public static string dpgettext(string domain, string msgctxtid, gsize msgidoffset)
183 	{
184 		// const gchar * g_dpgettext (const gchar *domain,  const gchar *msgctxtid,  gsize msgidoffset);
185 		return Str.toString(g_dpgettext(Str.toStringz(domain), Str.toStringz(msgctxtid), msgidoffset));
186 	}
187 	
188 	/**
189 	 * This function is a variant of g_dgettext() which supports
190 	 * a disambiguating message context. GNU gettext uses the
191 	 * '\004' character to separate the message context and
192 	 * message id in msgctxtid.
193 	 * This uses g_dgettext() internally. See that functions for differences
194 	 * with dgettext() proper.
195 	 * This function differs from C_() in that it is not a macro and
196 	 * thus you may use non-string-literals as context and msgid arguments.
197 	 * Since 2.18
198 	 * Params:
199 	 * domain = the translation domain to use, or NULL to use
200 	 * the domain set with textdomain(). [allow-none]
201 	 * context = the message context
202 	 * msgid = the message
203 	 * Returns: The translated string
204 	 */
205 	public static string dpgettext2(string domain, string context, string msgid)
206 	{
207 		// const gchar * g_dpgettext2 (const gchar *domain,  const gchar *context,  const gchar *msgid);
208 		return Str.toString(g_dpgettext2(Str.toStringz(domain), Str.toStringz(context), Str.toStringz(msgid)));
209 	}
210 	
211 	/**
212 	 * An auxiliary function for gettext() support (see Q_()).
213 	 * Since 2.4
214 	 * Params:
215 	 * msgid = a string
216 	 * msgval = another string
217 	 * Returns: msgval, unless msgval is identical to msgid and contains a '|' character, in which case a pointer to the substring of msgid after the first '|' character is returned.
218 	 */
219 	public static string stripContext(string msgid, string msgval)
220 	{
221 		// const gchar * g_strip_context (const gchar *msgid,  const gchar *msgval);
222 		return Str.toString(g_strip_context(Str.toStringz(msgid), Str.toStringz(msgval)));
223 	}
224 	
225 	/**
226 	 * Computes a list of applicable locale names, which can be used to
227 	 * e.g. construct locale-dependent filenames or search paths. The returned
228 	 * list is sorted from most desirable to least desirable and always contains
229 	 * the default locale "C".
230 	 * For example, if LANGUAGE=de:en_US, then the returned list is
231 	 * "de", "en_US", "en", "C".
232 	 * This function consults the environment variables LANGUAGE,
233 	 * LC_ALL, LC_MESSAGES and LANG
234 	 * to find the list of locales specified by the user.
235 	 * Since 2.6
236 	 * Returns: a NULL-terminated array of strings owned by GLib that must not be modified or freed. [array zero-terminated=1][transfer none]
237 	 */
238 	public static string[] getLanguageNames()
239 	{
240 		// const gchar * const * g_get_language_names (void);
241 		return Str.toStringArray(g_get_language_names());
242 	}
243 	
244 	/**
245 	 * Returns a list of derived variants of locale, which can be used to
246 	 * e.g. construct locale-dependent filenames or search paths. The returned
247 	 * list is sorted from most desirable to least desirable.
248 	 * This function handles territory, charset and extra locale modifiers.
249 	 * For example, if locale is "fr_BE", then the returned list
250 	 * is "fr_BE", "fr".
251 	 * If you need the list of variants for the current locale,
252 	 * use g_get_language_names().
253 	 * Since 2.28
254 	 * Params:
255 	 * locale = a locale identifier
256 	 * Returns: a newly allocated array of newly allocated strings with the locale variants. Free with g_strfreev(). [transfer full][array zero-terminated=1][element-type utf8]
257 	 */
258 	public static string[] getLocaleVariants(string locale)
259 	{
260 		// gchar ** g_get_locale_variants (const gchar *locale);
261 		return Str.toStringArray(g_get_locale_variants(Str.toStringz(locale)));
262 	}
263 }