pbutils: Move locale dir initialization to a separate function and do lazy initialization
It is the only thing gst_pb_utils_init() does and it could be automatically called from the places in pbutils it is needed. After 1.14 we should deprecate gst_pb_utils_init(). https://bugzilla.gnome.org/show_bug.cgi?id=793611
This commit is contained in:
parent
1a97338dc7
commit
006c7181ed
@ -434,6 +434,8 @@ format_info_get_desc (const FormatInfo * info, const GstCaps * caps)
|
|||||||
|
|
||||||
g_assert (info != NULL);
|
g_assert (info != NULL);
|
||||||
|
|
||||||
|
gst_pb_utils_init_locale_text_domain ();
|
||||||
|
|
||||||
if (info->desc != NULL)
|
if (info->desc != NULL)
|
||||||
return g_strdup (_(info->desc));
|
return g_strdup (_(info->desc));
|
||||||
|
|
||||||
@ -930,6 +932,8 @@ gst_pb_utils_get_source_description (const gchar * protocol)
|
|||||||
|
|
||||||
g_return_val_if_fail (protocol != NULL, NULL);
|
g_return_val_if_fail (protocol != NULL, NULL);
|
||||||
|
|
||||||
|
gst_pb_utils_init_locale_text_domain ();
|
||||||
|
|
||||||
if (strcmp (protocol, "cdda") == 0)
|
if (strcmp (protocol, "cdda") == 0)
|
||||||
return g_strdup (_("Audio CD source"));
|
return g_strdup (_("Audio CD source"));
|
||||||
|
|
||||||
@ -1019,6 +1023,8 @@ gst_pb_utils_get_decoder_description (const GstCaps * caps)
|
|||||||
|
|
||||||
g_return_val_if_fail (gst_caps_is_fixed (tmp), NULL);
|
g_return_val_if_fail (gst_caps_is_fixed (tmp), NULL);
|
||||||
|
|
||||||
|
gst_pb_utils_init_locale_text_domain ();
|
||||||
|
|
||||||
/* special-case RTP caps */
|
/* special-case RTP caps */
|
||||||
if (caps_are_rtp_caps (tmp, "video", &str)) {
|
if (caps_are_rtp_caps (tmp, "video", &str)) {
|
||||||
ret = g_strdup_printf (_("%s video RTP depayloader"), str);
|
ret = g_strdup_printf (_("%s video RTP depayloader"), str);
|
||||||
@ -1069,6 +1075,7 @@ gst_pb_utils_get_encoder_description (const GstCaps * caps)
|
|||||||
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
|
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
|
||||||
tmp = copy_and_clean_caps (caps);
|
tmp = copy_and_clean_caps (caps);
|
||||||
g_return_val_if_fail (gst_caps_is_fixed (tmp), NULL);
|
g_return_val_if_fail (gst_caps_is_fixed (tmp), NULL);
|
||||||
|
gst_pb_utils_init_locale_text_domain ();
|
||||||
|
|
||||||
/* special-case RTP caps */
|
/* special-case RTP caps */
|
||||||
if (caps_are_rtp_caps (tmp, "video", &str)) {
|
if (caps_are_rtp_caps (tmp, "video", &str)) {
|
||||||
@ -1117,6 +1124,8 @@ gst_pb_utils_get_element_description (const gchar * factory_name)
|
|||||||
|
|
||||||
g_return_val_if_fail (factory_name != NULL, NULL);
|
g_return_val_if_fail (factory_name != NULL, NULL);
|
||||||
|
|
||||||
|
gst_pb_utils_init_locale_text_domain ();
|
||||||
|
|
||||||
ret = g_strdup_printf (_("GStreamer element %s"), factory_name);
|
ret = g_strdup_printf (_("GStreamer element %s"), factory_name);
|
||||||
if (ret && g_str_has_prefix (ret, factory_name))
|
if (ret && g_str_has_prefix (ret, factory_name))
|
||||||
*ret = g_ascii_toupper (*ret);
|
*ret = g_ascii_toupper (*ret);
|
||||||
|
@ -368,6 +368,8 @@ get_locale (void)
|
|||||||
const char *loc = NULL;
|
const char *loc = NULL;
|
||||||
gchar *ret;
|
gchar *ret;
|
||||||
|
|
||||||
|
gst_pb_utils_init_locale_text_domain ();
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
#ifdef ENABLE_NLS
|
||||||
#if defined(LC_MESSAGES)
|
#if defined(LC_MESSAGES)
|
||||||
loc = setlocale (LC_MESSAGES, NULL);
|
loc = setlocale (LC_MESSAGES, NULL);
|
||||||
|
@ -112,3 +112,6 @@ struct _GstDiscovererInfo {
|
|||||||
/* missing-plugins.c */
|
/* missing-plugins.c */
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
GstCaps *copy_and_clean_caps (const GstCaps * caps);
|
GstCaps *copy_and_clean_caps (const GstCaps * caps);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
void gst_pb_utils_init_locale_text_domain (void);
|
||||||
|
@ -60,6 +60,25 @@
|
|||||||
|
|
||||||
#include "gst/gst-i18n-plugin.h"
|
#include "gst/gst-i18n-plugin.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
_init_locale_text_domain (void)
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_NLS
|
||||||
|
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
|
||||||
|
LOCALEDIR);
|
||||||
|
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||||
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_pb_utils_init_locale_text_domain (void)
|
||||||
|
{
|
||||||
|
static GOnce locale_init_once = G_ONCE_INIT;
|
||||||
|
|
||||||
|
g_once (&locale_init_once, _init_locale_text_domain, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_pb_utils_init:
|
* gst_pb_utils_init:
|
||||||
*
|
*
|
||||||
@ -79,12 +98,7 @@ gst_pb_utils_init (void)
|
|||||||
GST_LOG ("already initialised");
|
GST_LOG ("already initialised");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_NLS
|
gst_pb_utils_init_locale_text_domain ();
|
||||||
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
|
|
||||||
LOCALEDIR);
|
|
||||||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
|
||||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inited = TRUE;
|
inited = TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user