tests: fix glib_translations_work()
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Tue, 5 Jul 2011 13:30:31 +0000 (14:30 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 11 Jul 2011 04:08:14 +0000 (00:08 -0400)
If setlocale() to our test locale fails, translations
won't work either.

https://bugzilla.gnome.org/show_bug.cgi?id=654017

gio/tests/gsettings.c

index e178a05..ded8098 100644 (file)
@@ -1479,17 +1479,19 @@ test_child_schema (void)
 static gboolean
 glib_translations_work (void)
 {
+  gboolean works;
   gchar *locale;
   gchar *orig = "Unnamed";
-  gchar *str;
 
   locale = g_strdup (setlocale (LC_MESSAGES, NULL));
-  setlocale (LC_MESSAGES, "de");
-  str = dgettext ("glib20", orig);
+  if (!setlocale (LC_MESSAGES, "de"))
+    works = FALSE;
+  else
+    works = dgettext ("glib20", orig) != orig;
   setlocale (LC_MESSAGES, locale);
   g_free (locale);
 
-  return str != orig;
+  return works;
 }
 
 #include "../strinfo.c"