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 61 private import glib.Str; 62 63 64 65 66 /** 67 * GLib doesn't force any particular localization method upon its users. 68 * But since GLib itself is localized using the gettext() mechanism, it seems 69 * natural to offer the de-facto standard gettext() support macros in an 70 * easy-to-use form. 71 * 72 * In order to use these macros in an application, you must include 73 * glib/gi18n.h. For use in a library, you must include 74 * glib/gi18n-lib.h after defining 75 * the GETTEXT_PACKAGE macro suitably for your library: 76 * 77 * $(DDOC_COMMENT example) 78 * 79 * For an application, note that you also have to call bindtextdomain(), 80 * bind_textdomain_codeset(), textdomain() and setlocale() early on in your 81 * main() to make gettext() work. 82 * 83 * For a library, you only have to call bindtextdomain() and 84 * bind_textdomain_codeset() in your initialization function. If your library 85 * doesn't have an initialization function, you can call the functions before 86 * the first translated message. 87 * 88 * The gettext manual covers details of how to set up message extraction 89 * with xgettext. 90 */ 91 public class Internationalization 92 { 93 94 /** 95 */ 96 97 /** 98 * This function is a wrapper of dgettext() which does not translate 99 * the message if the default domain as set with textdomain() has no 100 * translations for the current locale. 101 * The advantage of using this function over dgettext() proper is that 102 * libraries using this function (like GTK+) will not use translations 103 * if the application using the library does not have translations for 104 * the current locale. This results in a consistent English-only 105 * interface instead of one having partial translations. For this 106 * feature to work, the call to textdomain() and setlocale() should 107 * precede any g_dgettext() invocations. For GTK+, it means calling 108 * textdomain() before gtk_init or its variants. 109 * This function disables translations if and only if upon its first 110 * Since 2.18 111 * Params: 112 * domain = the translation domain to use, or NULL to use 113 * the domain set with textdomain(). [allow-none] 114 * msgid = message to translate 115 * Returns: The translated string 116 */ 117 public static string dgettext(string domain, string msgid) 118 { 119 // const gchar * g_dgettext (const gchar *domain, const gchar *msgid); 120 return Str.toString(g_dgettext(Str.toStringz(domain), Str.toStringz(msgid))); 121 } 122 123 /** 124 * This is a variant of g_dgettext() that allows specifying a locale 125 * category instead of always using LC_MESSAGES. See g_dgettext() for 126 * more information about how this functions differs from calling 127 * dcgettext() directly. 128 * Since 2.26 129 * Params: 130 * domain = the translation domain to use, or NULL to use 131 * the domain set with textdomain(). [allow-none] 132 * msgid = message to translate 133 * category = a locale category 134 * Returns: the translated string for the given locale category 135 */ 136 public static string dcgettext(string domain, string msgid, int category) 137 { 138 // const gchar * g_dcgettext (const gchar *domain, const gchar *msgid, gint category); 139 return Str.toString(g_dcgettext(Str.toStringz(domain), Str.toStringz(msgid), category)); 140 } 141 142 /** 143 * This function is a wrapper of dngettext() which does not translate 144 * the message if the default domain as set with textdomain() has no 145 * translations for the current locale. 146 * See g_dgettext() for details of how this differs from dngettext() 147 * proper. 148 * Since 2.18 149 * Params: 150 * domain = the translation domain to use, or NULL to use 151 * the domain set with textdomain(). [allow-none] 152 * msgid = message to translate 153 * msgidPlural = plural form of the message 154 * n = the quantity for which translation is needed 155 * Returns: The translated string 156 */ 157 public static string dngettext(string domain, string msgid, string msgidPlural, gulong n) 158 { 159 // const gchar * g_dngettext (const gchar *domain, const gchar *msgid, const gchar *msgid_plural, gulong n); 160 return Str.toString(g_dngettext(Str.toStringz(domain), Str.toStringz(msgid), Str.toStringz(msgidPlural), n)); 161 } 162 163 /** 164 * This function is a variant of g_dgettext() which supports 165 * a disambiguating message context. GNU gettext uses the 166 * '\004' character to separate the message context and 167 * message id in msgctxtid. 168 * If 0 is passed as msgidoffset, this function will fall back to 169 * trying to use the deprecated convention of using "|" as a separation 170 * character. 171 * This uses g_dgettext() internally. See that functions for differences 172 * with dgettext() proper. 173 * Applications should normally not use this function directly, 174 * but use the C_() macro for translations with context. 175 * Since 2.16 176 * Params: 177 * domain = the translation domain to use, or NULL to use 178 * the domain set with textdomain(). [allow-none] 179 * msgctxtid = a combined message context and message id, separated 180 * by a \004 character 181 * msgidoffset = the offset of the message id in msgctxid 182 * Returns: The translated string 183 */ 184 public static string dpgettext(string domain, string msgctxtid, gsize msgidoffset) 185 { 186 // const gchar * g_dpgettext (const gchar *domain, const gchar *msgctxtid, gsize msgidoffset); 187 return Str.toString(g_dpgettext(Str.toStringz(domain), Str.toStringz(msgctxtid), msgidoffset)); 188 } 189 190 /** 191 * This function is a variant of g_dgettext() which supports 192 * a disambiguating message context. GNU gettext uses the 193 * '\004' character to separate the message context and 194 * message id in msgctxtid. 195 * This uses g_dgettext() internally. See that functions for differences 196 * with dgettext() proper. 197 * This function differs from C_() in that it is not a macro and 198 * thus you may use non-string-literals as context and msgid arguments. 199 * Since 2.18 200 * Params: 201 * domain = the translation domain to use, or NULL to use 202 * the domain set with textdomain(). [allow-none] 203 * context = the message context 204 * msgid = the message 205 * Returns: The translated string 206 */ 207 public static string dpgettext2(string domain, string context, string msgid) 208 { 209 // const gchar * g_dpgettext2 (const gchar *domain, const gchar *context, const gchar *msgid); 210 return Str.toString(g_dpgettext2(Str.toStringz(domain), Str.toStringz(context), Str.toStringz(msgid))); 211 } 212 213 /** 214 * An auxiliary function for gettext() support (see Q_()). 215 * Since 2.4 216 * Params: 217 * msgid = a string 218 * msgval = another string 219 * 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. 220 */ 221 public static string stripContext(string msgid, string msgval) 222 { 223 // const gchar * g_strip_context (const gchar *msgid, const gchar *msgval); 224 return Str.toString(g_strip_context(Str.toStringz(msgid), Str.toStringz(msgval))); 225 } 226 227 /** 228 * Computes a list of applicable locale names, which can be used to 229 * e.g. construct locale-dependent filenames or search paths. The returned 230 * list is sorted from most desirable to least desirable and always contains 231 * the default locale "C". 232 * For example, if LANGUAGE=de:en_US, then the returned list is 233 * "de", "en_US", "en", "C". 234 * This function consults the environment variables LANGUAGE, 235 * LC_ALL, LC_MESSAGES and LANG 236 * to find the list of locales specified by the user. 237 * Since 2.6 238 * Returns: a NULL-terminated array of strings owned by GLib that must not be modified or freed. [array zero-terminated=1][transfer none] 239 */ 240 public static string[] getLanguageNames() 241 { 242 // const gchar * const * g_get_language_names (void); 243 return Str.toStringArray(g_get_language_names()); 244 } 245 246 /** 247 * Returns a list of derived variants of locale, which can be used to 248 * e.g. construct locale-dependent filenames or search paths. The returned 249 * list is sorted from most desirable to least desirable. 250 * This function handles territory, charset and extra locale modifiers. 251 * For example, if locale is "fr_BE", then the returned list 252 * is "fr_BE", "fr". 253 * If you need the list of variants for the current locale, 254 * use g_get_language_names(). 255 * Since 2.28 256 * Params: 257 * locale = a locale identifier 258 * 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] 259 */ 260 public static string[] getLocaleVariants(string locale) 261 { 262 // gchar ** g_get_locale_variants (const gchar *locale); 263 return Str.toStringArray(g_get_locale_variants(Str.toStringz(locale))); 264 } 265 }