dgettext


Description:

[ Version ( since = "2.18" ) ]
[ CCode ( cname = "g_dgettext" ) ]
public unowned string dgettext (string? domain, string msgid)

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 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.

Parameters:

domain

the translation domain to use, or null to use the domain set with textdomain

msgid

message to translate

Returns:

The translated string


Namespace: GLib
Package: glib-2.0