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 module glib.Internationalization;
26 
27 private import glib.Str;
28 private import glib.c.functions;
29 public  import glib.c.types;
30 
31 
32 /** */
33 public struct Internationalization
34 {
35 
36 	/**
37 	 * This is a variant of g_dgettext() that allows specifying a locale
38 	 * category instead of always using `LC_MESSAGES`. See g_dgettext() for
39 	 * more information about how this functions differs from calling
40 	 * dcgettext() directly.
41 	 *
42 	 * Params:
43 	 *     domain = the translation domain to use, or %NULL to use
44 	 *         the domain set with textdomain()
45 	 *     msgid = message to translate
46 	 *     category = a locale category
47 	 *
48 	 * Returns: the translated string for the given locale category
49 	 *
50 	 * Since: 2.26
51 	 */
52 	public static string dcgettext(string domain, string msgid, int category)
53 	{
54 		return Str.toString(g_dcgettext(Str.toStringz(domain), Str.toStringz(msgid), category));
55 	}
56 
57 	/**
58 	 * This function is a wrapper of dgettext() which does not translate
59 	 * the message if the default domain as set with textdomain() has no
60 	 * translations for the current locale.
61 	 *
62 	 * The advantage of using this function over dgettext() proper is that
63 	 * libraries using this function (like GTK+) will not use translations
64 	 * if the application using the library does not have translations for
65 	 * the current locale.  This results in a consistent English-only
66 	 * interface instead of one having partial translations.  For this
67 	 * feature to work, the call to textdomain() and setlocale() should
68 	 * precede any g_dgettext() invocations.  For GTK+, it means calling
69 	 * textdomain() before gtk_init or its variants.
70 	 *
71 	 * This function disables translations if and only if upon its first
72 	 * call all the following conditions hold:
73 	 *
74 	 * - @domain is not %NULL
75 	 *
76 	 * - textdomain() has been called to set a default text domain
77 	 *
78 	 * - there is no translations available for the default text domain
79 	 * and the current locale
80 	 *
81 	 * - current locale is not "C" or any English locales (those
82 	 * starting with "en_")
83 	 *
84 	 * Note that this behavior may not be desired for example if an application
85 	 * has its untranslated messages in a language other than English. In those
86 	 * cases the application should call textdomain() after initializing GTK+.
87 	 *
88 	 * Applications should normally not use this function directly,
89 	 * but use the _() macro for translations.
90 	 *
91 	 * Params:
92 	 *     domain = the translation domain to use, or %NULL to use
93 	 *         the domain set with textdomain()
94 	 *     msgid = message to translate
95 	 *
96 	 * Returns: The translated string
97 	 *
98 	 * Since: 2.18
99 	 */
100 	public static string dgettext(string domain, string msgid)
101 	{
102 		return Str.toString(g_dgettext(Str.toStringz(domain), Str.toStringz(msgid)));
103 	}
104 
105 	/**
106 	 * This function is a wrapper of dngettext() which does not translate
107 	 * the message if the default domain as set with textdomain() has no
108 	 * translations for the current locale.
109 	 *
110 	 * See g_dgettext() for details of how this differs from dngettext()
111 	 * proper.
112 	 *
113 	 * Params:
114 	 *     domain = the translation domain to use, or %NULL to use
115 	 *         the domain set with textdomain()
116 	 *     msgid = message to translate
117 	 *     msgidPlural = plural form of the message
118 	 *     n = the quantity for which translation is needed
119 	 *
120 	 * Returns: The translated string
121 	 *
122 	 * Since: 2.18
123 	 */
124 	public static string dngettext(string domain, string msgid, string msgidPlural, gulong n)
125 	{
126 		return Str.toString(g_dngettext(Str.toStringz(domain), Str.toStringz(msgid), Str.toStringz(msgidPlural), n));
127 	}
128 
129 	/**
130 	 * This function is a variant of g_dgettext() which supports
131 	 * a disambiguating message context. GNU gettext uses the
132 	 * '\004' character to separate the message context and
133 	 * message id in @msgctxtid.
134 	 * If 0 is passed as @msgidoffset, this function will fall back to
135 	 * trying to use the deprecated convention of using "|" as a separation
136 	 * character.
137 	 *
138 	 * This uses g_dgettext() internally. See that functions for differences
139 	 * with dgettext() proper.
140 	 *
141 	 * Applications should normally not use this function directly,
142 	 * but use the C_() macro for translations with context.
143 	 *
144 	 * Params:
145 	 *     domain = the translation domain to use, or %NULL to use
146 	 *         the domain set with textdomain()
147 	 *     msgctxtid = a combined message context and message id, separated
148 	 *         by a \004 character
149 	 *     msgidoffset = the offset of the message id in @msgctxid
150 	 *
151 	 * Returns: The translated string
152 	 *
153 	 * Since: 2.16
154 	 */
155 	public static string dpgettext(string domain, string msgctxtid, size_t msgidoffset)
156 	{
157 		return Str.toString(g_dpgettext(Str.toStringz(domain), Str.toStringz(msgctxtid), msgidoffset));
158 	}
159 
160 	/**
161 	 * This function is a variant of g_dgettext() which supports
162 	 * a disambiguating message context. GNU gettext uses the
163 	 * '\004' character to separate the message context and
164 	 * message id in @msgctxtid.
165 	 *
166 	 * This uses g_dgettext() internally. See that functions for differences
167 	 * with dgettext() proper.
168 	 *
169 	 * This function differs from C_() in that it is not a macro and
170 	 * thus you may use non-string-literals as context and msgid arguments.
171 	 *
172 	 * Params:
173 	 *     domain = the translation domain to use, or %NULL to use
174 	 *         the domain set with textdomain()
175 	 *     context = the message context
176 	 *     msgid = the message
177 	 *
178 	 * Returns: The translated string
179 	 *
180 	 * Since: 2.18
181 	 */
182 	public static string dpgettext2(string domain, string context, string msgid)
183 	{
184 		return Str.toString(g_dpgettext2(Str.toStringz(domain), Str.toStringz(context), Str.toStringz(msgid)));
185 	}
186 
187 	/**
188 	 * Computes a list of applicable locale names, which can be used to
189 	 * e.g. construct locale-dependent filenames or search paths. The returned
190 	 * list is sorted from most desirable to least desirable and always contains
191 	 * the default locale "C".
192 	 *
193 	 * For example, if LANGUAGE=de:en_US, then the returned list is
194 	 * "de", "en_US", "en", "C".
195 	 *
196 	 * This function consults the environment variables `LANGUAGE`, `LC_ALL`,
197 	 * `LC_MESSAGES` and `LANG` to find the list of locales specified by the
198 	 * user.
199 	 *
200 	 * Returns: a %NULL-terminated array of strings owned by GLib
201 	 *     that must not be modified or freed.
202 	 *
203 	 * Since: 2.6
204 	 */
205 	public static string[] getLanguageNames()
206 	{
207 		return Str.toStringArray(g_get_language_names());
208 	}
209 
210 	/**
211 	 * Returns a list of derived variants of @locale, which can be used to
212 	 * e.g. construct locale-dependent filenames or search paths. The returned
213 	 * list is sorted from most desirable to least desirable.
214 	 * This function handles territory, charset and extra locale modifiers. See
215 	 * [`setlocale(3)`](man:setlocale) for information about locales and their format.
216 	 *
217 	 * @locale itself is guaranteed to be returned in the output.
218 	 *
219 	 * For example, if @locale is `fr_BE`, then the returned list
220 	 * is `fr_BE`, `fr`. If @locale is `en_GB.UTF-8@euro`, then the returned list
221 	 * is `en_GB.UTF-8@euro`, `en_GB.UTF-8`, `en_GB@euro`, `en_GB`, `en.UTF-8@euro`,
222 	 * `en.UTF-8`, `en@euro`, `en`.
223 	 *
224 	 * If you need the list of variants for the current locale,
225 	 * use g_get_language_names().
226 	 *
227 	 * Params:
228 	 *     locale = a locale identifier
229 	 *
230 	 * Returns: a newly
231 	 *     allocated array of newly allocated strings with the locale variants. Free with
232 	 *     g_strfreev().
233 	 *
234 	 * Since: 2.28
235 	 */
236 	public static string[] getLocaleVariants(string locale)
237 	{
238 		auto retStr = g_get_locale_variants(Str.toStringz(locale));
239 
240 		scope(exit) Str.freeStringArray(retStr);
241 		return Str.toStringArray(retStr);
242 	}
243 
244 	/**
245 	 * An auxiliary function for gettext() support (see Q_()).
246 	 *
247 	 * Params:
248 	 *     msgid = a string
249 	 *     msgval = another string
250 	 *
251 	 * Returns: @msgval, unless @msgval is identical to @msgid
252 	 *     and contains a '|' character, in which case a pointer to
253 	 *     the substring of msgid after the first '|' character is returned.
254 	 *
255 	 * Since: 2.4
256 	 */
257 	public static string stripContext(string msgid, string msgval)
258 	{
259 		return Str.toString(g_strip_context(Str.toStringz(msgid), Str.toStringz(msgval)));
260 	}
261 }