]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Additional fixes for Hong Kong locale (<rdar://problem/22130168>)
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Mon, 10 Aug 2015 17:07:30 +0000 (17:07 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Mon, 10 Aug 2015 17:07:30 +0000 (17:07 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12841 a1ca3aef-8c08-0410-bb20-df032aa958be

cups/language.c
cups/ppd.c
cups/testlang.c

index 00c740054596785f26096ba2db526b1d3c50911d..69e391f2a8df96b084894a273faf197ee20c3fb6 100644 (file)
@@ -1180,7 +1180,7 @@ appleLangDefault(void)
          * See if we have an Info.plist file in the bundle...
          */
 
-         CFStringGetCString(cfpath, path,sizeof(path), kCFStringEncodingUTF8);
+         CFStringGetCString(cfpath, path, sizeof(path), kCFStringEncodingUTF8);
          DEBUG_printf(("3appleLangDefault: Got a resource URL (\"%s\")", path));
          strlcat(path, "Contents/Info.plist", sizeof(path));
 
@@ -1211,7 +1211,6 @@ appleLangDefault(void)
 
     if (localizationList)
     {
-
 #ifdef DEBUG
       if (CFGetTypeID(localizationList) == CFArrayGetTypeID())
         DEBUG_printf(("3appleLangDefault: Got localizationList, %d entries.",
@@ -1287,6 +1286,8 @@ appleLangDefault(void)
       strlcpy(cg->language, "en_US.UTF-8", sizeof(cg->language));
     }
   }
+  else
+    DEBUG_printf(("3appleLangDefault: Using previous locale \"%s\".", cg->language));
 
  /*
   * Return the cached locale...
index d1f9cadf963082166df3c8c6bad2e66781d98230..504e26932693537d19b9abb51f43776a1a812e4a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * PPD file routines for CUPS.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  * These coded instructions, statements, and computer programs are the
@@ -418,10 +418,10 @@ _ppdOpen(
   char                 custom_name[PPD_MAX_NAME];
                                        /* CustomFoo attribute name */
   ppd_attr_t           *custom_attr;   /* CustomFoo attribute */
-  char                 ll[4],          /* Language + '.' */
-                       ll_CC[7];       /* Language country + '.' */
-  size_t               ll_len = 0,     /* Language length */
-                       ll_CC_len = 0;  /* Language country length */
+  char                 ll[7],          /* Base language + '.' */
+                       ll_CC[7];       /* Language w/country + '.' */
+  size_t               ll_len = 0,     /* Base language length */
+                       ll_CC_len = 0;  /* Language w/country length */
   static const char * const ui_keywords[] =
                        {
 #ifdef CUPS_USE_FULL_UI_KEYWORDS_LIST
@@ -519,7 +519,17 @@ _ppdOpen(
       return (NULL);
 
     snprintf(ll_CC, sizeof(ll_CC), "%s.", lang->language);
-    snprintf(ll, sizeof(ll), "%2.2s.", lang->language);
+
+   /*
+    * <rdar://problem/22130168>
+    *
+    * Need to use a different base language for some locales...
+    */
+
+    if (!strcmp(lang->language, "zh_HK"))
+      strlcpy(ll, "zh_TW.", sizeof(ll));
+    else
+      snprintf(ll, sizeof(ll), "%2.2s.", lang->language);
 
     ll_CC_len = strlen(ll_CC);
     ll_len    = strlen(ll);
index 701c14db404f564d459efc3137da87e947911844..b00505da4e7bb168d8c638d89016c551e3b465d9 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   Localization test program for CUPS.
  *
- *   Copyright 2007-2010 by Apple Inc.
+ *   Copyright 2007-2015 by Apple Inc.
  *   Copyright 1997-2006 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -50,8 +50,6 @@ main(int  argc,                               /* I - Number of command-line arguments */
   };
 
 
-  _cupsSetLocale(argv);
-
   if (argc == 1)
   {
     language  = cupsLangDefault();
@@ -61,8 +59,13 @@ main(int  argc,                              /* I - Number of command-line arguments */
   {
     language  = cupsLangGet(argv[1]);
     language2 = cupsLangGet(argv[1]);
+
+    setenv("LANG", argv[1], 1);
+    setenv("SOFTWARE", "CUPS/" CUPS_SVERSION, 1);
   }
 
+  _cupsSetLocale(argv);
+
   if (language != language2)
   {
     errors ++;
@@ -105,6 +108,45 @@ main(int  argc,                            /* I - Number of command-line arguments */
     }
   }
 
+  if (argc == 3)
+  {
+    ppd_file_t         *ppd;           /* PPD file */
+    ppd_option_t       *option;        /* PageSize option */
+    ppd_choice_t       *choice;        /* PageSize/Letter choice */
+
+    if ((ppd = ppdOpenFile(argv[2])) == NULL)
+    {
+      printf("Unable to open PPD file \"%s\".\n", argv[2]);
+      errors ++;
+    }
+    else
+    {
+      ppdLocalize(ppd);
+
+      if ((option = ppdFindOption(ppd, "PageSize")) == NULL)
+      {
+        puts("No PageSize option.");
+        errors ++;
+      }
+      else
+      {
+        printf("PageSize: %s\n", option->text);
+
+        if ((choice = ppdFindChoice(option, "Letter")) == NULL)
+        {
+         puts("No Letter PageSize choice.");
+         errors ++;
+        }
+        else
+        {
+         printf("Letter: %s\n", choice->text);
+        }
+      }
+
+      ppdClose(ppd);
+    }
+  }
+
   return (errors > 0);
 }