GLib.dgettext
function dgettext(domain: String, msgid: String): String { // Gjs wrapper for g_dgettext() }
This function is a wrapper of dgettext() which does not translate the message if the default domain as set with textdomain() has no translations for the current locale.
The advantage of using this function over dgettext() proper is that libraries using this function (like GTK+) will not use translations if the application using the library does not have translations for the current locale. This results in a consistent English-only interface instead of one having partial translations. For this feature to work, the call to textdomain() and setlocale() should precede any GLib.dgettext invocations. For GTK+, it means calling textdomain() before gtk_init or its variants.
This function disables translations if and only if upon its first call all the following conditions hold:
- domain is not null
- textdomain() has been called to set a default text domain
- there is no translations available for the default text domain and the current locale
- current locale is not "C" or any English locales (those starting with "en_")
Note that this behavior may not be desired for example if an application has its untranslated messages in a language other than English. In those cases the application should call textdomain() after initializing GTK+.
Applications should normally not use this function directly, but use the _() macro for translations.
Since 2.18
- domain
the translation domain to use, or null to use the domain set with textdomain()
- msgid
message to translate
- Returns
The translated string