From e1fb92551f7be3dbaad9d9a5c80dc30ed7b83048 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Tue, 11 May 2010 19:48:19 +0200 Subject: [PATCH] check for working gettext() before running tests --- gio/tests/gsettings.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c index 3987e5b..1801724 100644 --- a/gio/tests/gsettings.c +++ b/gio/tests/gsettings.c @@ -532,8 +532,6 @@ test_atomic (void) g_object_unref (settings); } -#ifndef G_OS_WIN32 - /* On Windows the interaction between the C library locale and libintl * (from GNU gettext) is not like on POSIX, so just skip these tests * for now. @@ -633,8 +631,6 @@ test_l10n_context (void) g_free (locale); } -#endif - enum { PROP_0, @@ -1169,6 +1165,22 @@ test_child_schema (void) g_object_unref (settings); } +static gboolean +glib_translations_work (void) +{ + gchar *locale; + gchar *orig = "Unnamed"; + gchar *str; + + locale = g_strdup (setlocale (LC_MESSAGES, NULL)); + setlocale (LC_MESSAGES, "de"); + str = dgettext ("glib20", orig); + setlocale (LC_MESSAGES, locale); + g_free (locale); + + return str != orig; +} + int main (int argc, char *argv[]) { @@ -1191,10 +1203,13 @@ main (int argc, char *argv[]) g_test_add_func ("/gsettings/basic-types", test_basic_types); g_test_add_func ("/gsettings/complex-types", test_complex_types); g_test_add_func ("/gsettings/changes", test_changes); -#ifndef G_OS_WIN32 - g_test_add_func ("/gsettings/l10n", test_l10n); - g_test_add_func ("/gsettings/l10n-context", test_l10n_context); -#endif + + if (glib_translations_work ()) + { + g_test_add_func ("/gsettings/l10n", test_l10n); + g_test_add_func ("/gsettings/l10n-context", test_l10n_context); + } + g_test_add_func ("/gsettings/delay-apply", test_delay_apply); g_test_add_func ("/gsettings/delay-revert", test_delay_revert); g_test_add_func ("/gsettings/atomic", test_atomic); -- 2.7.4