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