|
| 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 01:26:02.490096103 +0900 |
| 4 | +@@ -302,51 +302,7 @@ |
| 5 | + static gboolean |
| 6 | + _g_dgettext_should_translate (void) |
| 7 | + { |
| 8 | +- static gsize translate = 0; |
| 9 | +- enum { |
| 10 | +- SHOULD_TRANSLATE = 1, |
| 11 | +- SHOULD_NOT_TRANSLATE = 2 |
| 12 | +- }; |
| 13 | +- |
| 14 | +- if (G_UNLIKELY (g_once_init_enter (&translate))) |
| 15 | +- { |
| 16 | +- gboolean should_translate = TRUE; |
| 17 | +- |
| 18 | +- const char *default_domain = textdomain (NULL); |
| 19 | +- const char *translator_comment = gettext (""); |
| 20 | +-#ifndef G_OS_WIN32 |
| 21 | +- const char *translate_locale = setlocale (LC_MESSAGES, NULL); |
| 22 | +-#else |
| 23 | +- const char *translate_locale = g_win32_getlocale (); |
| 24 | +-#endif |
| 25 | +- /* We should NOT translate only if all the following hold: |
| 26 | +- * - user has called textdomain() and set textdomain to non-default |
| 27 | +- * - default domain has no translations |
| 28 | +- * - locale does not start with "en_" and is not "C" |
| 29 | +- * |
| 30 | +- * Rationale: |
| 31 | +- * - If text domain is still the default domain, maybe user calls |
| 32 | +- * it later. Continue with old behavior of translating. |
| 33 | +- * - If locale starts with "en_", we can continue using the |
| 34 | +- * translations even if the app doesn't have translations for |
| 35 | +- * this locale. That is, en_UK and en_CA for example. |
| 36 | +- * - If locale is "C", maybe user calls setlocale(LC_ALL,"") later. |
| 37 | +- * Continue with old behavior of translating. |
| 38 | +- */ |
| 39 | +- if (!default_domain || !translator_comment || !translate_locale || |
| 40 | +- (0 != strcmp (default_domain, "messages") && |
| 41 | +- '\0' == *translator_comment && |
| 42 | +- 0 != strncmp (translate_locale, "en_", 3) && |
| 43 | +- 0 != strcmp (translate_locale, "C"))) |
| 44 | +- should_translate = FALSE; |
| 45 | +- |
| 46 | +- g_once_init_leave (&translate, |
| 47 | +- should_translate ? |
| 48 | +- SHOULD_TRANSLATE : |
| 49 | +- SHOULD_NOT_TRANSLATE); |
| 50 | +- } |
| 51 | +- |
| 52 | +- return translate == SHOULD_TRANSLATE; |
| 53 | ++ return false; |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | +@@ -396,10 +352,7 @@ |
| 58 | + g_dgettext (const gchar *domain, |
| 59 | + const gchar *msgid) |
| 60 | + { |
| 61 | +- if (domain && G_UNLIKELY (!_g_dgettext_should_translate ())) |
| 62 | +- return msgid; |
| 63 | +- |
| 64 | +- return dgettext (domain, msgid); |
| 65 | ++ return msgid; |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | +@@ -423,10 +376,7 @@ |
| 70 | + const gchar *msgid, |
| 71 | + gint category) |
| 72 | + { |
| 73 | +- if (domain && G_UNLIKELY (!_g_dgettext_should_translate ())) |
| 74 | +- return msgid; |
| 75 | +- |
| 76 | +- return dcgettext (domain, msgid, category); |
| 77 | ++ return msgid; |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | +@@ -454,10 +404,7 @@ |
| 82 | + const gchar *msgid_plural, |
| 83 | + gulong n) |
| 84 | + { |
| 85 | +- if (domain && G_UNLIKELY (!_g_dgettext_should_translate ())) |
| 86 | +- return n == 1 ? msgid : msgid_plural; |
| 87 | +- |
| 88 | +- return dngettext (domain, msgid, msgid_plural, n); |
| 89 | ++ return n == 1 ? msgid : msgid_plural; |
| 90 | + } |
| 91 | + |
| 92 | + |
0 commit comments