summaryrefslogtreecommitdiff
path: root/ppdc
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2014-04-08 19:53:57 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2014-04-08 19:53:57 +0000
commitbe76a9737d617abeb227fc79d9990af7c4bbbd19 (patch)
tree67175639eff73e0b812a37a1fe68eae9c41170d9 /ppdc
parent698fa0aa4afef894089053fdb61986aeff2d19a7 (diff)
downloadcups-be76a9737d617abeb227fc79d9990af7c4bbbd19.tar.gz
Make sure that the sample drivers include all installed localizations
(<rdar://problem/14756625>) git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11800 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'ppdc')
-rw-r--r--ppdc/Makefile6
-rw-r--r--ppdc/genstrings.cxx27
-rw-r--r--ppdc/ppdc-catalog.cxx96
-rw-r--r--ppdc/ppdc.cxx23
-rw-r--r--ppdc/sample.drv71
5 files changed, 152 insertions, 71 deletions
diff --git a/ppdc/Makefile b/ppdc/Makefile
index 0943d10b3..1bf09dd6a 100644
--- a/ppdc/Makefile
+++ b/ppdc/Makefile
@@ -3,7 +3,7 @@
#
# Makefile for the CUPS PPD Compiler.
#
-# Copyright 2007-2013 by Apple Inc.
+# Copyright 2007-2014 by Apple Inc.
# Copyright 2002-2006 by Easy Software Products.
#
# These coded instructions, statements, and computer programs are the
@@ -290,9 +290,9 @@ ppdi-static: ppdc-static ppdi.o libcupsppdc.a ../cups/$(LIBCUPSSTATIC)
$(COMMONLIBS) $(LIBZ)
echo Testing PPD importer...
$(RM) -r ppd ppd2 sample-import.drv
- ./ppdc-static -I ../data sample.drv
+ ./ppdc-static -l en -I ../data sample.drv
./ppdi-static -I ../data -o sample-import.drv ppd/*
- ./ppdc-static -I ../data -d ppd2 sample-import.drv
+ ./ppdc-static -l en -I ../data -d ppd2 sample-import.drv
if diff -r ppd ppd2 >/dev/null; then \
echo PPD import OK; \
else \
diff --git a/ppdc/genstrings.cxx b/ppdc/genstrings.cxx
index d08416d32..8d0061ba0 100644
--- a/ppdc/genstrings.cxx
+++ b/ppdc/genstrings.cxx
@@ -1,31 +1,24 @@
//
// "$Id$"
//
-// GNU gettext message generator for the CUPS PPD Compiler.
+// GNU gettext message generator for the CUPS PPD Compiler.
//
-// This program is used to generate a dummy source file containing all of
-// the standard media and sample driver strings. The results are picked up
-// by GNU gettext and placed in the CUPS message catalog.
+// This program is used to generate a dummy source file containing all of
+// the standard media and sample driver strings. The results are picked up
+// by GNU gettext and placed in the CUPS message catalog.
//
-// Copyright 2008-2011 by Apple Inc.
+// Copyright 2008-2014 by Apple Inc.
//
-// These coded instructions, statements, and computer programs are the
-// property of Apple Inc. and are protected by Federal copyright
-// law. Distribution and use rights are outlined in the file "LICENSE.txt"
-// which should have been included with this file. If this file is
-// file is missing or damaged, see the license at "http://www.cups.org/".
+// These coded instructions, statements, and computer programs are the
+// property of Apple Inc. and are protected by Federal copyright
+// law. Distribution and use rights are outlined in the file "LICENSE.txt"
+// which should have been included with this file. If this file is
+// file is missing or damaged, see the license at "http://www.cups.org/".
//
// Usage:
//
// ./genstrings >sample.c
//
-// Contents:
-//
-// main() - Main entry for the PPD compiler.
-// add_ui_strings() - Add all UI strings from the driver.
-// write_cstring() - Write a translation string as a valid C string to
-// stdout.
-//
//
// Include necessary headers...
diff --git a/ppdc/ppdc-catalog.cxx b/ppdc/ppdc-catalog.cxx
index 1bf46566f..567163731 100644
--- a/ppdc/ppdc-catalog.cxx
+++ b/ppdc/ppdc-catalog.cxx
@@ -37,6 +37,9 @@ typedef enum
// Local functions...
//
+#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR)
+static void apple_add_message(CFStringRef key, CFStringRef val, ppdcCatalog *c);
+#endif /* __APPLE__ && CUPS_BUNDLEDIR */
static int get_utf8(char *&ptr);
static int get_utf16(cups_file_t *fp, ppdc_cs_t &cs);
static int put_utf8(int ch, char *&ptr, char *end);
@@ -51,10 +54,6 @@ ppdcCatalog::ppdcCatalog(const char *l, // I - Locale
const char *f) // I - Message catalog file
: ppdcShared()
{
- _cups_globals_t *cg = _cupsGlobals();
- // Global information
-
-
PPDC_NEW;
locale = new ppdcString(l);
@@ -67,6 +66,67 @@ ppdcCatalog::ppdcCatalog(const char *l, // I - Locale
char pofile[1024]; // Message catalog file
+#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR)
+ char applelang[256]; // Apple language ID
+ CFURLRef url; // URL to cups.strings file
+ CFReadStreamRef stream = NULL; // File stream
+ CFPropertyListRef plist = NULL; // Localization file
+
+ snprintf(pofile, sizeof(pofile), CUPS_BUNDLEDIR "/Resources/%s.lproj/cups.strings", _cupsAppleLanguage(l, applelang, sizeof(applelang)));
+ if (access(pofile, 0))
+ {
+ // Try alternate lproj directory names...
+ const char *tl = l; // Temporary locale string
+
+ if (!strncmp(l, "en", 2))
+ tl = "English";
+ else if (!strncmp(l, "nb", 2) || !strncmp(l, "nl", 2))
+ tl = "Dutch";
+ else if (!strncmp(l, "fr", 2))
+ tl = "French";
+ else if (!strncmp(l, "de", 2))
+ tl = "German";
+ else if (!strncmp(l, "it", 2))
+ tl = "Italian";
+ else if (!strncmp(l, "ja", 2))
+ tl = "Japanese";
+ else if (!strncmp(l, "es", 2))
+ tl = "Spanish";
+
+ snprintf(pofile, sizeof(pofile), CUPS_BUNDLEDIR "/Resources/%s.lproj/cups.strings", tl);
+ }
+
+ url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (UInt8 *)pofile, (CFIndex)strlen(pofile), false);
+ if (url)
+ {
+ stream = CFReadStreamCreateWithFile(kCFAllocatorDefault, url);
+
+ if (stream)
+ {
+ /*
+ * Read the property list containing the localization data.
+ */
+
+ CFReadStreamOpen(stream);
+
+ plist = CFPropertyListCreateWithStream(kCFAllocatorDefault, stream, 0, kCFPropertyListImmutable, NULL, NULL);
+
+ if (plist && CFGetTypeID(plist) == CFDictionaryGetTypeID())
+ CFDictionaryApplyFunction((CFDictionaryRef)plist, (CFDictionaryApplierFunction)apple_add_message, this);
+
+ if (plist)
+ CFRelease(plist);
+
+ CFRelease(stream);
+ }
+
+ CFRelease(url);
+ }
+
+#else
+ _cups_globals_t *cg = _cupsGlobals();
+ // Global information
+
snprintf(pofile, sizeof(pofile), "%s/%s/cups_%s.po", cg->localedir, l, l);
if (load_messages(pofile) && strchr(l, '_'))
@@ -81,9 +141,10 @@ ppdcCatalog::ppdcCatalog(const char *l, // I - Locale
load_messages(pofile);
}
+#endif /* __APPLE__ && CUPS_BUNDLEDIR */
}
- if (f)
+ if (f && *f)
load_messages(f);
}
@@ -193,8 +254,8 @@ ppdcCatalog::load_messages(
else if (!strcmp(ptr, ".strings"))
{
/*
- * Read messages in OS X ".strings" format, which are UTF-16 text files of
- * the format:
+ * Read messages in OS X ".strings" format, which are either UTF-8/UTF-16
+ * text files of the format:
*
* "id" = "str";
*
@@ -597,6 +658,27 @@ ppdcCatalog::save_messages(
}
+#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR)
+//
+// 'apple_add_message()' - Add a message from a localization dictionary.
+//
+
+static void
+apple_add_message(CFStringRef key, // I - Localization key
+ CFStringRef val, // I - Localized value
+ ppdcCatalog *c) // I - Message catalog
+{
+ char id[1024], // Message id
+ str[1024]; // Localized message
+
+
+ if (CFStringGetCString(key, id, sizeof(id), kCFStringEncodingUTF8) &&
+ CFStringGetCString(val, str, sizeof(str), kCFStringEncodingUTF8))
+ c->add_message(id, str);
+}
+#endif /* __APPLE__ && CUPS_BUNDLEDIR */
+
+
//
// 'get_utf8()' - Get a UTF-8 character.
//
diff --git a/ppdc/ppdc.cxx b/ppdc/ppdc.cxx
index 9074df173..67d3b6690 100644
--- a/ppdc/ppdc.cxx
+++ b/ppdc/ppdc.cxx
@@ -1,21 +1,16 @@
//
// "$Id$"
//
-// PPD file compiler main entry for the CUPS PPD Compiler.
+// PPD file compiler main entry for the CUPS PPD Compiler.
//
-// Copyright 2007-2012 by Apple Inc.
-// Copyright 2002-2007 by Easy Software Products.
+// Copyright 2007-2014 by Apple Inc.
+// Copyright 2002-2007 by Easy Software Products.
//
-// These coded instructions, statements, and computer programs are the
-// property of Apple Inc. and are protected by Federal copyright
-// law. Distribution and use rights are outlined in the file "LICENSE.txt"
-// which should have been included with this file. If this file is
-// file is missing or damaged, see the license at "http://www.cups.org/".
-//
-// Contents:
-//
-// main() - Main entry for the PPD compiler.
-// usage() - Show usage and exit.
+// These coded instructions, statements, and computer programs are the
+// property of Apple Inc. and are protected by Federal copyright
+// law. Distribution and use rights are outlined in the file "LICENSE.txt"
+// which should have been included with this file. If this file is
+// file is missing or damaged, see the license at "http://www.cups.org/".
//
//
@@ -192,7 +187,7 @@ main(int argc, // I - Number of command-line arguments
catalog = new ppdcCatalog(argv[i]);
- if (catalog->messages->count == 0)
+ if (catalog->messages->count == 0 && strcmp(argv[i], "en"))
{
_cupsLangPrintf(stderr,
_("ppdc: Unable to find localization for "
diff --git a/ppdc/sample.drv b/ppdc/sample.drv
index 22fffa14c..1d487004c 100644
--- a/ppdc/sample.drv
+++ b/ppdc/sample.drv
@@ -1,16 +1,16 @@
//
// "$Id$"
//
-// Driver info file for CUPS-supplied PPDs.
+// Driver info file for CUPS-supplied PPDs.
//
-// Copyright 2007-2012 by Apple Inc.
-// Copyright 1993-2006 by Easy Software Products.
+// Copyright 2007-2014 by Apple Inc.
+// Copyright 1993-2006 by Easy Software Products.
//
-// These coded instructions, statements, and computer programs are the
-// property of Apple Inc. and are protected by Federal copyright
-// law. Distribution and use rights are outlined in the file "LICENSE.txt"
-// which should have been included with this file. If this file is
-// file is missing or damaged, see the license at "http://www.cups.org/".
+// These coded instructions, statements, and computer programs are the
+// property of Apple Inc. and are protected by Federal copyright
+// law. Distribution and use rights are outlined in the file "LICENSE.txt"
+// which should have been included with this file. If this file is
+// file is missing or damaged, see the license at "http://www.cups.org/".
//
// Include necessary files...
@@ -22,26 +22,37 @@
// Localizations are provided for all of the base languages supported by
// CUPS...
-//#po da ""
-//#po de ""
-//#po es ""
-//#po et ""
-//#po fi ""
-//#po fr ""
-//#po he ""
-//#po id ""
-//#po it ""
-//#po ja ""
-//#po ko ""
-//#po nl ""
-//#po no ""
-//#po pl ""
-//#po pt ""
-//#po pt_BR ""
-//#po ru ""
-//#po sv ""
-//#po zh ""
-//#po zh_TW ""
+#po ar ""
+#po ca ""
+#po cs ""
+#po da ""
+#po de ""
+#po el ""
+#po es ""
+#po fi ""
+#po fr ""
+#po he ""
+#po hr ""
+#po hu ""
+#po id ""
+#po it ""
+#po ja ""
+#po ko ""
+#po ms ""
+#po no ""
+#po pl ""
+#po pt ""
+#po pt_PT ""
+#po ro ""
+#po ru ""
+#po sk ""
+#po sv ""
+#po th ""
+#po tr ""
+#po uk ""
+#po vi ""
+#po zh_CN ""
+#po zh_TW ""
// MediaSize sizes used by label drivers...
#media "w90h18/1.25x0.25\"" 90 18
@@ -108,7 +119,7 @@ Attribute "FileSystem" "" "False"
Attribute "LandscapeOrientation" "" "Plus90"
Attribute "TTRasterizer" "" "Type42"
-Copyright "Copyright 2007-2013 by Apple Inc."
+Copyright "Copyright 2007-2014 by Apple Inc."
Copyright "Copyright 1997-2007 by Easy Software Products."
Copyright ""
Copyright "These coded instructions, statements, and computer programs are the"
@@ -119,7 +130,7 @@ Copyright "file is missing or damaged, see the license at \"http://www.cups.org/
Font *
-Version "1.5"
+Version "2.0"
// Dymo Label Printer
{