]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/language.c
Import CUPS v2.0.2
[thirdparty/cups.git] / cups / language.c
index 035f9d259963cd8bf1ac0db4ef087a5634222285..7888af09894e000ef63044f8302f11eeb30b926d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: language.c 11558 2014-02-06 18:33:34Z msweet $"
+ * "$Id: language.c 12266 2014-11-19 16:05:28Z msweet $"
  *
  * I18N/language support for CUPS.
  *
@@ -1139,7 +1139,7 @@ appleLangDefault(void)
   int                  i;              /* Looping var */
   CFBundleRef          bundle;         /* Main bundle (if any) */
   CFArrayRef           bundleList;     /* List of localizations in bundle */
-  CFPropertyListRef    localizationList;
+  CFPropertyListRef    localizationList = NULL;
                                        /* List of localization data */
   CFStringRef          languageName;   /* Current name */
   CFStringRef          localeName;     /* Canonical from of name */
@@ -1165,14 +1165,42 @@ appleLangDefault(void)
     else if ((bundle = CFBundleGetMainBundle()) != NULL &&
              (bundleList = CFBundleCopyBundleLocalizations(bundle)) != NULL)
     {
+      CFURLRef resources = CFBundleCopyResourcesDirectoryURL(bundle);
+
       DEBUG_puts("3appleLangDefault: Getting localizationList from bundle.");
 
-      localizationList =
-         CFBundleCopyPreferredLocalizationsFromArray(bundleList);
+      if (resources)
+      {
+        CFStringRef    cfpath = CFURLCopyPath(resources);
+       char            path[1024];
+
+        if (cfpath)
+       {
+        /*
+         * See if we have an Info.plist file in the bundle...
+         */
+
+         CFStringGetCString(cfpath, path,sizeof(path), kCFStringEncodingUTF8);
+         DEBUG_printf(("3appleLangDefault: Got a resource URL (\"%s\")", path));
+         strlcat(path, "Contents/Info.plist", sizeof(path));
+
+          if (!access(path, R_OK))
+           localizationList = CFBundleCopyPreferredLocalizationsFromArray(bundleList);
+         else
+           DEBUG_puts("3appleLangDefault: No Info.plist, ignoring resource URL...");
+
+         CFRelease(cfpath);
+       }
+
+       CFRelease(resources);
+      }
+      else
+        DEBUG_puts("3appleLangDefault: No resource URL.");
 
       CFRelease(bundleList);
     }
-    else
+
+    if (!localizationList)
     {
       DEBUG_puts("3appleLangDefault: Getting localizationList from preferences.");
 
@@ -1560,5 +1588,5 @@ cups_unquote(char       *d,               /* O - Unquoted string */
 
 
 /*
- * End of "$Id: language.c 11558 2014-02-06 18:33:34Z msweet $".
+ * End of "$Id: language.c 12266 2014-11-19 16:05:28Z msweet $".
  */