Function glib::dgettext

source ·
pub fn dgettext(domain: Option<&str>, msgid: &str) -> GString
Expand description

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 g_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 None

  • textdomain() has been called to set a default text domain

  • there is no translations available for the default text domCreates a new instance of a Object subtype and sets its properties.

Construction parameters (see ParamFlags::CONSTRUCT, ParamFlags::CONSTRUCT_ONLY) which are not explicitly specified are set to their default values. Any private data for the object is guaranteed to be initialized with zeros, as per g_type_create_instance().

Note that in C, small integer types in variable argument lists are promoted up to gint or guint as appropriate, and read back accordingly. gint is 32 bits on every platform on which GLib is currently supported. This means that you can use C expressions of type gint with [new()][Self::new()] and properties of type gint or guint or smaller. Specifically, you can use integer literals with these property types.

When using property types of gint64 or guint64, you must ensure that the value that you provide is 64 bit. This means that you should use a cast or make use of the G_GINT64_CONSTANT or G_GUINT64_CONSTANT macros.

Similarly, gfloat is promoted to gdouble, so you must ensure that the value you provide is a gdouble, even for a property of type gfloat.

Since GLib 2.72, all GObjects are guaranteed to be aligned to at least the alignment of the largest basic GLib type (typically this is guint64 or gdouble). If you need larger alignment for an element in a Object, you should allocate it on the heap (aligned), or arrange for your Object to be appropriately padded.

§object_type

the type id of the Object subtype to instantiate

§first_property_name

the name of the first property

§Returns

a new instance of object_type 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 g_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 None

  • textdomain() has been called to set a default text domain

  • there is no translations available for the default text domCreates a new instance of a Object subtype and sets its properties.

Construction parameters (see ParamFlags::CONSTRUCT, ParamFlags::CONSTRUCT_ONLY) which are not explicitly specified are set to their default values. Any private data for the object is guaranteed to be initialized with zeros, as per g_type_create_instance().

Note that in C, small integer types in variable argument lists are promoted up to gint or guint as appropriate, and read back accordingly. gint is 32 bits on every platform on which GLib is currently supported. This means that you can use C expressions of type gint with [new()][Self::new()] and properties of type gint or guint or smaller. Specifically, you can use integer literals with these property types.

When using property types of gint64 or guint64, you must ensure that the value that you provide is 64 bit. This means that you should use a cast or make use of the G_GINT64_CONSTANT or G_GUINT64_CONSTANT macros.

Similarly, gfloat is promoted to gdouble, so you must ensure that the value you provide is a gdouble, even for a property of type gfloat.

Since GLib 2.72, all GObjects are guaranteed to be aligned to at least the alignment of the largest basic GLib type (typically this is guint64 or gdouble). If you need larger alignment for an element in a Object, you should allocate it on the heap (aligned), or arrange for your Object to be appropriately padded.

§object_type

the type id of the Object subtype to instantiate

§first_property_name

the name of the first property

§Returns

a new instance of object_type