From 313a0fffe5343012517fb3c6980d04aa59749b9c Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Sat, 9 Jun 2018 02:30:20 +0800 Subject: [PATCH 1/2] tests: Use de_DE.UTF-8 instead of de_DE in gsettings test FreeBSD doesn't have a de_DE locale without encoding suffix. --- gio/tests/gsettings.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c index 2f056ee95..93e819244 100644 --- a/gio/tests/gsettings.c +++ b/gio/tests/gsettings.c @@ -749,7 +749,7 @@ test_l10n (void) g_free (str); str = NULL; - setlocale (LC_MESSAGES, "de_DE"); + setlocale (LC_MESSAGES, "de_DE.UTF-8"); /* Only do the test if translation is actually working... */ if (g_str_equal (dgettext ("test", "\"Unnamed\""), "\"Unbenannt\"")) { @@ -796,7 +796,7 @@ test_l10n_context (void) g_free (str); str = NULL; - setlocale (LC_MESSAGES, "de_DE"); + setlocale (LC_MESSAGES, "de_DE.UTF-8"); /* Only do the test if translation is actually working... */ if (g_str_equal (dgettext ("test", "\"Unnamed\""), "\"Unbenannt\"")) { From 6f2b3503a5eed17b7d1bd4423e86e0ed902bf946 Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Sat, 26 May 2018 01:26:43 +0800 Subject: [PATCH 2/2] 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. --- gio/tests/gapplication.c | 2 ++ gio/tests/gdbus-serialization.c | 1 + gio/tests/gsettings.c | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/gio/tests/gapplication.c b/gio/tests/gapplication.c index 336135cb4..f5491ec9e 100644 --- a/gio/tests/gapplication.c +++ b/gio/tests/gapplication.c @@ -972,6 +972,8 @@ test_api (void) int main (int argc, char **argv) { + g_setenv ("LC_ALL", "C", TRUE); + g_test_init (&argc, &argv, NULL); g_test_dbus_unset (); diff --git a/gio/tests/gdbus-serialization.c b/gio/tests/gdbus-serialization.c index da28f1bc1..d2f0a6ce7 100644 --- a/gio/tests/gdbus-serialization.c +++ b/gio/tests/gdbus-serialization.c @@ -1085,6 +1085,7 @@ int main (int argc, char *argv[]) { + g_setenv ("LC_ALL", "C", TRUE); setlocale (LC_ALL, "C"); g_test_init (&argc, &argv, NULL); diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c index 93e819244..ba80647f1 100644 --- a/gio/tests/gsettings.c +++ b/gio/tests/gsettings.c @@ -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);