source: appstream-generator/build/girepo/glib/Internationalization.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

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