]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix the localization fallback code on macOS (rdar://33583699)
authorMichael Sweet <michael.r.sweet@gmail.com>
Wed, 9 Aug 2017 17:43:08 +0000 (13:43 -0400)
committerMichael Sweet <michael.r.sweet@gmail.com>
Wed, 9 Aug 2017 17:43:08 +0000 (13:43 -0400)
CHANGES.md
cups/language.c
cups/testlang.c

index 62a8b81a99b1e868c34184976ab6867dd5571474..e88df3b20f52631194a808facc438934e525a738 100644 (file)
@@ -38,6 +38,7 @@ CHANGES IN CUPS V2.2.5
 - CUPS now sends the `Date` HTTP header in IPP requests (rdar://33302034)
 - The `ippCopyAttribute` function did not copy out-of-band values correctly
   (rdar://33688003)
+- Fixed the localization fallback code on macOS (rdar://33583699)
 - The `ipptool` program now offers an option to validate response headers.
 
 
index ec10fc77c760e4ad338e90977ea89f8d87884a52..626c1316a11293f528373447339eb0a3fc50af1a 100644 (file)
@@ -1468,8 +1468,8 @@ appleMessageLoad(const char *locale)      /* I - Locale ID */
       */
 
       strlcpy(baselang, locale, sizeof(baselang));
-      if (baselang[3] == '-' || baselang[3] == '_')
-        baselang[3] = '\0';
+      if (baselang[2] == '-' || baselang[2] == '_')
+        baselang[2] = '\0';
 
       locale = baselang;
     }
index d6c9fddaa6025c107ace32a0fa40448a91efa80f..e205711e6385fdde83a27e2c8355a73bcd27bf10 100644 (file)
@@ -37,6 +37,8 @@ main(int  argc,                               /* I - Number of command-line arguments */
   cups_lang_t          *language;      /* Message catalog */
   cups_lang_t          *language2;     /* Message catalog */
   struct lconv         *loc;           /* Locale data */
+  const char            *msgid,         /* String identifier */
+                        *msgstr;        /* Localized string */
   char                 buffer[1024];   /* String buffer */
   double               number;         /* Number */
   static const char * const tests[] =  /* Test strings */
@@ -74,8 +76,26 @@ main(int  argc,                              /* I - Number of command-line arguments */
 
   printf("Language = \"%s\"\n", language->language);
   printf("Encoding = \"%s\"\n", _cupsEncodingName(language->encoding));
-  printf("No       = \"%s\"\n", _cupsLangString(language, "No"));
-  printf("Yes      = \"%s\"\n", _cupsLangString(language, "Yes"));
+
+  msgid  = "No";
+  msgstr = _cupsLangString(language, msgid);
+  if (msgid == msgstr)
+  {
+    printf("%-8s = \"%s\" (FAIL)\n", msgid, msgstr);
+    errors ++;
+  }
+  else
+    printf("%-8s = \"%s\" (PASS)\n", msgid, msgstr);
+
+  msgid  = "Yes";
+  msgstr = _cupsLangString(language, msgid);
+  if (msgid == msgstr)
+  {
+    printf("%-8s = \"%s\" (FAIL)\n", msgid, msgstr);
+    errors ++;
+  }
+  else
+    printf("%-8s = \"%s\" (PASS)\n", msgid, msgstr);
 
   if (language != language2)
   {