|
| 1 | +diff -ru glib-2.65.1-orig/glib/ggettext.c glib-2.65.1/glib/ggettext.c |
| 2 | +--- glib-2.65.1-orig/glib/ggettext.c 2020-08-07 23:31:53.019354800 +0900 |
| 3 | ++++ glib-2.65.1/glib/ggettext.c 2020-08-21 11:27:44.678064916 +0900 |
| 4 | +@@ -95,22 +95,6 @@ |
| 5 | + static void |
| 6 | + ensure_gettext_initialized (void) |
| 7 | + { |
| 8 | +- static gsize initialised; |
| 9 | +- |
| 10 | +- if (g_once_init_enter (&initialised)) |
| 11 | +- { |
| 12 | +-#ifdef G_OS_WIN32 |
| 13 | +- gchar *tmp = _glib_get_locale_dir (); |
| 14 | +- bindtextdomain (GETTEXT_PACKAGE, tmp); |
| 15 | +- g_free (tmp); |
| 16 | +-#else |
| 17 | +- bindtextdomain (GETTEXT_PACKAGE, GLIB_LOCALE_DIR); |
| 18 | +-#endif |
| 19 | +-# ifdef HAVE_BIND_TEXTDOMAIN_CODESET |
| 20 | +- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); |
| 21 | +-# endif |
| 22 | +- g_once_init_leave (&initialised, TRUE); |
| 23 | +- } |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | +@@ -302,51 +286,7 @@ |
| 28 | + static gboolean |
| 29 | + _g_dgettext_should_translate (void) |
| 30 | + { |
| 31 | +- static gsize translate = 0; |
| 32 | +- enum { |
| 33 | +- SHOULD_TRANSLATE = 1, |
| 34 | +- SHOULD_NOT_TRANSLATE = 2 |
| 35 | +- }; |
| 36 | +- |
| 37 | +- if (G_UNLIKELY (g_once_init_enter (&translate))) |
| 38 | +- { |
| 39 | +- gboolean should_translate = TRUE; |
| 40 | +- |
| 41 | +- const char *default_domain = textdomain (NULL); |
| 42 | +- const char *translator_comment = gettext (""); |
| 43 | +-#ifndef G_OS_WIN32 |
| 44 | +- const char *translate_locale = setlocale (LC_MESSAGES, NULL); |
| 45 | +-#else |
| 46 | +- const char *translate_locale = g_win32_getlocale (); |
| 47 | +-#endif |
| 48 | +- /* We should NOT translate only if all the following hold: |
| 49 | +- * - user has called textdomain() and set textdomain to non-default |
| 50 | +- * - default domain has no translations |
| 51 | +- * - locale does not start with "en_" and is not "C" |
| 52 | +- * |
| 53 | +- * Rationale: |
| 54 | +- * - If text domain is still the default domain, maybe user calls |
| 55 | +- * it later. Continue with old behavior of translating. |
| 56 | +- * - If locale starts with "en_", we can continue using the |
| 57 | +- * translations even if the app doesn't have translations for |
| 58 | +- * this locale. That is, en_UK and en_CA for example. |
| 59 | +- * - If locale is "C", maybe user calls setlocale(LC_ALL,"") later. |
| 60 | +- * Continue with old behavior of translating. |
| 61 | +- */ |
| 62 | +- if (!default_domain || !translator_comment || !translate_locale || |
| 63 | +- (0 != strcmp (default_domain, "messages") && |
| 64 | +- '\0' == *translator_comment && |
| 65 | +- 0 != strncmp (translate_locale, "en_", 3) && |
| 66 | +- 0 != strcmp (translate_locale, "C"))) |
| 67 | +- should_translate = FALSE; |
| 68 | +- |
| 69 | +- g_once_init_leave (&translate, |
| 70 | +- should_translate ? |
| 71 | +- SHOULD_TRANSLATE : |
| 72 | +- SHOULD_NOT_TRANSLATE); |
| 73 | +- } |
| 74 | +- |
| 75 | +- return translate == SHOULD_TRANSLATE; |
| 76 | ++ return 0; |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | +@@ -396,10 +336,7 @@ |
| 81 | + g_dgettext (const gchar *domain, |
| 82 | + const gchar *msgid) |
| 83 | + { |
| 84 | +- if (domain && G_UNLIKELY (!_g_dgettext_should_translate ())) |
| 85 | +- return msgid; |
| 86 | +- |
| 87 | +- return dgettext (domain, msgid); |
| 88 | ++ return msgid; |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | +@@ -423,10 +360,7 @@ |
| 93 | + const gchar *msgid, |
| 94 | + gint category) |
| 95 | + { |
| 96 | +- if (domain && G_UNLIKELY (!_g_dgettext_should_translate ())) |
| 97 | +- return msgid; |
| 98 | +- |
| 99 | +- return dcgettext (domain, msgid, category); |
| 100 | ++ return msgid; |
| 101 | + } |
| 102 | + |
| 103 | + /** |
| 104 | +@@ -454,10 +388,7 @@ |
| 105 | + const gchar *msgid_plural, |
| 106 | + gulong n) |
| 107 | + { |
| 108 | +- if (domain && G_UNLIKELY (!_g_dgettext_should_translate ())) |
| 109 | +- return n == 1 ? msgid : msgid_plural; |
| 110 | +- |
| 111 | +- return dngettext (domain, msgid, msgid_plural, n); |
| 112 | ++ return n == 1 ? msgid : msgid_plural; |
| 113 | + } |
| 114 | + |
| 115 | + |
0 commit comments