]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
cupsLangDefault() now maps new-style Apple locale name to the
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 30 Apr 2007 17:55:15 +0000 (17:55 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 30 Apr 2007 17:55:15 +0000 (17:55 +0000)
traditional ll_CC form (STR #2357)

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@6489 7a7537e8-13f0-0310-91df-b6672ffda945

CHANGES.txt
cups/language.c

index 65d9cab749ea15facb2712cdd9c8d79e847744e2..f5b0e3d9b475b811235f8ff259fa630b41e6be94 100644 (file)
@@ -3,7 +3,10 @@ CHANGES.txt - 2007-04-25
 
 CHANGES IN CUPS V1.3
 
-       - Documentation updates (STR #1775, STR #2130, STR #2131)
+       - Documentation updates (STR #1775, STR #2130, STR #2131,
+         STR #2356)
+       - cupsLangDefault() now maps new-style Apple locale names
+         to the traditional ll_CC form (STR #2357)
         - Add new cupsArrayNew2() API to support hashed lookups
           of array elements (STR #2358)
         - ppdConflicts() optimizations (STR #2358)
index 2dcd0d3804e715bf0754fd003a35d607b9b4eee7..6d387c3a76120cff65b2a3cdab35939115a22d7a 100644 (file)
@@ -984,6 +984,21 @@ _cupsMessageLookup(cups_array_t *a,        /* I - Message array */
  */
 
 #  ifdef HAVE_CF_LOCALE_ID
+
+typedef struct
+{
+  const char * const name;             /* Language name */
+  const char * const locale;           /* Locale name */
+} _apple_name_locale_t;
+
+static const _apple_name_locale_t apple_name_locale[] =
+{
+  { "en"       , "en_US" },
+  { "no"       , "nb"    },
+  { "zh-Hans"  , "zh_CN" },
+  { "zh-Hant"  , "zh_TW" }
+};
+
 /*
  * 'appleLangDefault()' - Get the default locale string.
  */
@@ -991,6 +1006,7 @@ _cupsMessageLookup(cups_array_t *a,        /* I - Message array */
 static const char *                    /* O - Locale string */
 appleLangDefault(void)
 {
+  int                  i;              /* Looping var */
   CFPropertyListRef    localizationList;
                                        /* List of localization data */
   CFStringRef          languageName;   /* Current name */
@@ -1033,9 +1049,30 @@ appleLangDefault(void)
                                 kCFStringEncodingASCII);
              CFRelease(localeName);
 
-             if (!strcmp(cg->language, "en"))
-               strlcpy(cg->language, "en_US.UTF-8", sizeof(cg->language));
-             else if (strchr(cg->language, '.') == NULL)
+            /*
+             * Map new language identifiers to locales...
+             */
+
+             for (i = 0;
+                  i < sizeof(apple_name_locale) / sizeof(apple_name_locale[0]);
+                  i++)
+             {
+               if (!strcmp(cg->language, apple_name_locale[i].name))
+               {
+                 strlcpy(cg->language, apple_name_locale[i].locale, 
+                         sizeof(cg->language));
+                 break;
+               }
+             }
+
+            /*
+             * Convert language subtag into region subtag...
+             */
+
+             if (cg->language[2] == '-')
+               cg->language[2] = '_';
+
+             if (strchr(cg->language, '.') == NULL)
                strlcat(cg->language, ".UTF-8", sizeof(cg->language));
            }
           }