mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-28 16:36:14 +01:00
Correct internal definition of C_()
* Since the GLib translations are lazily initialized, we need an internal wrapper for g_dpgettext() that does the initialization in the same way as glib_gettext() * We need to use the glib domain defined by GETTEXT_PACKAGE rather than than the application's domain. https://bugzilla.gnome.org/show_bug.cgi?id=644607
This commit is contained in:
parent
88d23f0285
commit
789b341eff
@ -5,7 +5,9 @@
|
|||||||
#error "config.h must be included prior to glibintl.h"
|
#error "config.h must be included prior to glibintl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
G_CONST_RETURN gchar *glib_gettext (const gchar *str) G_GNUC_FORMAT(1);
|
G_CONST_RETURN gchar *glib_gettext (const gchar *str) G_GNUC_FORMAT(1);
|
||||||
|
G_CONST_RETURN gchar *glib_pgettext (const gchar *msgctxtid,
|
||||||
|
gsize msgidoffset) G_GNUC_FORMAT(1);
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
#ifdef ENABLE_NLS
|
||||||
|
|
||||||
@ -13,7 +15,7 @@ G_CONST_RETURN gchar *glib_gettext (const gchar *str) G_GNUC_FORMAT(1);
|
|||||||
#define _(String) glib_gettext(String)
|
#define _(String) glib_gettext(String)
|
||||||
/* Split out this in the code, but keep it in the same domain for now */
|
/* Split out this in the code, but keep it in the same domain for now */
|
||||||
#define P_(String) glib_gettext(String)
|
#define P_(String) glib_gettext(String)
|
||||||
#define C_(Context,String) g_dpgettext (NULL, Context "\004" String, strlen (Context) + 1)
|
#define C_(Context,String) glib_pgettext (Context "\004" String, strlen (Context) + 1)
|
||||||
|
|
||||||
#ifdef gettext_noop
|
#ifdef gettext_noop
|
||||||
#define N_(String) gettext_noop(String)
|
#define N_(String) gettext_noop(String)
|
||||||
|
@ -3611,18 +3611,8 @@ _glib_get_locale_dir (void)
|
|||||||
|
|
||||||
#endif /* G_OS_WIN32 */
|
#endif /* G_OS_WIN32 */
|
||||||
|
|
||||||
/**
|
static void
|
||||||
* glib_gettext:
|
ensure_gettext_initialized(void)
|
||||||
* @str: The string to be translated
|
|
||||||
*
|
|
||||||
* Returns the translated string from the glib translations.
|
|
||||||
* This is an internal function and should only be used by
|
|
||||||
* the internals of glib (such as libgio).
|
|
||||||
*
|
|
||||||
* Returns: the transation of @str to the current locale
|
|
||||||
*/
|
|
||||||
G_CONST_RETURN gchar *
|
|
||||||
glib_gettext (const gchar *str)
|
|
||||||
{
|
{
|
||||||
static gboolean _glib_gettext_initialized = FALSE;
|
static gboolean _glib_gettext_initialized = FALSE;
|
||||||
|
|
||||||
@ -3640,10 +3630,50 @@ glib_gettext (const gchar *str)
|
|||||||
# endif
|
# endif
|
||||||
_glib_gettext_initialized = TRUE;
|
_glib_gettext_initialized = TRUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* glib_gettext:
|
||||||
|
* @str: The string to be translated
|
||||||
|
*
|
||||||
|
* Returns the translated string from the glib translations.
|
||||||
|
* This is an internal function and should only be used by
|
||||||
|
* the internals of glib (such as libgio).
|
||||||
|
*
|
||||||
|
* Returns: the transation of @str to the current locale
|
||||||
|
*/
|
||||||
|
G_CONST_RETURN gchar *
|
||||||
|
glib_gettext (const gchar *str)
|
||||||
|
{
|
||||||
|
ensure_gettext_initialized();
|
||||||
|
|
||||||
return g_dgettext (GETTEXT_PACKAGE, str);
|
return g_dgettext (GETTEXT_PACKAGE, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* glib_pgettext:
|
||||||
|
* @msgctxtid: a combined message context and message id, separated
|
||||||
|
* by a \004 character
|
||||||
|
* @msgidoffset: the offset of the message id in @msgctxid
|
||||||
|
*
|
||||||
|
* This function is a variant of glib_gettext() which supports
|
||||||
|
* a disambiguating message context. See g_dpgettext() for full
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* This is an internal function and should only be used by
|
||||||
|
* the internals of glib (such as libgio).
|
||||||
|
*
|
||||||
|
* Returns: the transation of @str to the current locale
|
||||||
|
*/
|
||||||
|
G_CONST_RETURN gchar *
|
||||||
|
glib_pgettext(const gchar *msgctxtid,
|
||||||
|
gsize msgidoffset)
|
||||||
|
{
|
||||||
|
ensure_gettext_initialized();
|
||||||
|
|
||||||
|
return g_dpgettext (GETTEXT_PACKAGE, msgctxtid, msgidoffset);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined (G_OS_WIN32) && !defined (_WIN64)
|
#if defined (G_OS_WIN32) && !defined (_WIN64)
|
||||||
|
|
||||||
/* Binary compatibility versions. Not for newly compiled code. */
|
/* Binary compatibility versions. Not for newly compiled code. */
|
||||||
|
Loading…
Reference in New Issue
Block a user