Commit 006c7181 authored by Thiago Santos's avatar Thiago Santos Committed by Sebastian Dröge

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
parent 1a97338d
......@@ -434,6 +434,8 @@ format_info_get_desc (const FormatInfo * info, const GstCaps * caps)
g_assert (info != NULL);
gst_pb_utils_init_locale_text_domain ();
if (info->desc != NULL)
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);
gst_pb_utils_init_locale_text_domain ();
if (strcmp (protocol, "cdda") == 0)
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);
gst_pb_utils_init_locale_text_domain ();
/* special-case RTP caps */
if (caps_are_rtp_caps (tmp, "video", &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);
tmp = copy_and_clean_caps (caps);
g_return_val_if_fail (gst_caps_is_fixed (tmp), NULL);
gst_pb_utils_init_locale_text_domain ();
/* special-case RTP caps */
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);
gst_pb_utils_init_locale_text_domain ();
ret = g_strdup_printf (_("GStreamer element %s"), factory_name);
if (ret && g_str_has_prefix (ret, factory_name))
*ret = g_ascii_toupper (*ret);
......
......@@ -368,6 +368,8 @@ get_locale (void)
const char *loc = NULL;
gchar *ret;
gst_pb_utils_init_locale_text_domain ();
#ifdef ENABLE_NLS
#if defined(LC_MESSAGES)
loc = setlocale (LC_MESSAGES, NULL);
......
......@@ -112,3 +112,6 @@ struct _GstDiscovererInfo {
/* missing-plugins.c */
G_GNUC_INTERNAL
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"
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:
*
......@@ -79,12 +98,7 @@ gst_pb_utils_init (void)
GST_LOG ("already initialised");
return;
}
#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
gst_pb_utils_init_locale_text_domain ();
inited = TRUE;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment