mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-04 08:23:38 +02:00
tests: Set both environment variable and locale when running tests
Non-glibc gettext implementation seems to decide the language from LC_MESSAGES environment variable instead of LC_MESSAGES locale, so we should set both environment variable and locale when running tests which need translation from specific languages.
This commit is contained in:
@@ -741,14 +741,17 @@ test_l10n (void)
|
||||
|
||||
settings = g_settings_new ("org.gtk.test.localized");
|
||||
|
||||
g_setenv ("LC_MESSAGES", "C", TRUE);
|
||||
setlocale (LC_MESSAGES, "C");
|
||||
str = g_settings_get_string (settings, "error-message");
|
||||
g_setenv ("LC_MESSAGES", locale, TRUE);
|
||||
setlocale (LC_MESSAGES, locale);
|
||||
|
||||
g_assert_cmpstr (str, ==, "Unnamed");
|
||||
g_free (str);
|
||||
str = NULL;
|
||||
|
||||
g_setenv ("LC_MESSAGES", "de_DE.UTF-8", TRUE);
|
||||
setlocale (LC_MESSAGES, "de_DE.UTF-8");
|
||||
/* Only do the test if translation is actually working... */
|
||||
if (g_str_equal (dgettext ("test", "\"Unnamed\""), "\"Unbenannt\""))
|
||||
@@ -762,6 +765,7 @@ test_l10n (void)
|
||||
else
|
||||
g_printerr ("warning: translation is not working... skipping test. ");
|
||||
|
||||
g_setenv ("LC_MESSAGES", locale, TRUE);
|
||||
setlocale (LC_MESSAGES, locale);
|
||||
g_free (locale);
|
||||
g_object_unref (settings);
|
||||
@@ -788,14 +792,17 @@ test_l10n_context (void)
|
||||
|
||||
settings = g_settings_new ("org.gtk.test.localized");
|
||||
|
||||
g_setenv ("LC_MESSAGES", "C", TRUE);
|
||||
setlocale (LC_MESSAGES, "C");
|
||||
g_settings_get (settings, "backspace", "s", &str);
|
||||
g_setenv ("LC_MESSAGES", locale, TRUE);
|
||||
setlocale (LC_MESSAGES, locale);
|
||||
|
||||
g_assert_cmpstr (str, ==, "BackSpace");
|
||||
g_free (str);
|
||||
str = NULL;
|
||||
|
||||
g_setenv ("LC_MESSAGES", "de_DE.UTF-8", TRUE);
|
||||
setlocale (LC_MESSAGES, "de_DE.UTF-8");
|
||||
/* Only do the test if translation is actually working... */
|
||||
if (g_str_equal (dgettext ("test", "\"Unnamed\""), "\"Unbenannt\""))
|
||||
@@ -809,6 +816,7 @@ test_l10n_context (void)
|
||||
else
|
||||
g_printerr ("warning: translation is not working... skipping test. ");
|
||||
|
||||
g_setenv ("LC_MESSAGES", locale, TRUE);
|
||||
setlocale (LC_MESSAGES, locale);
|
||||
g_free (locale);
|
||||
g_object_unref (settings);
|
||||
|
Reference in New Issue
Block a user