]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/localize.c
Merge changes from CUPS 1.4svn-r7696.
[thirdparty/cups.git] / cups / localize.c
index 551dde98e8e03d572ad9832acc61ce5bdd8454f1..7a98607de1b0d0648c7ea7a9984106c8d91b43c6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: localize.c 7363 2008-03-03 22:19:24Z mike $"
+ * "$Id: localize.c 7679 2008-06-19 23:37:45Z mike $"
  *
  *   PPD localization routines for the Common UNIX Printing System (CUPS).
  *
@@ -26,6 +26,7 @@
  * Contents:
  *
  *   ppdLocalize()           - Localize the PPD file to the current locale.
+ *   ppdLocalizeAttr()       - Localize an attribute.
  *   ppdLocalizeIPPReason()  - Get the localized version of a cupsIPPReason
  *                             attribute.
  *   ppdLocalizeMarkerName() - Get the localized version of a marker-names
@@ -195,6 +196,45 @@ ppdLocalize(ppd_file_t *ppd)               /* I - PPD file */
 }
 
 
+/*
+ * 'ppdLocalizeAttr()' - Localize an attribute.
+ *
+ * This function uses the current locale to find the localized attribute for
+ * the given main and option keywords.  If no localized version of the
+ * attribute exists for the current locale, the unlocalized version is returned.
+ */
+
+ppd_attr_t *                           /* O - Localized attribute or @code NULL@ if none exists */
+ppdLocalizeAttr(ppd_file_t *ppd,       /* I - PPD file */
+               const char *keyword,    /* I - Main keyword */
+               const char *spec)       /* I - Option keyword or @code NULL@ for none */
+{
+  ppd_attr_t   *locattr;               /* Localized attribute */
+  char         ll_CC[6];               /* Language + country locale */
+
+
+ /*
+  * Get the default language...
+  */
+
+  ppd_ll_CC(ll_CC, sizeof(ll_CC));
+
+ /*
+  * Find the localized attribute...
+  */
+
+  if (spec)
+    locattr = _ppdLocalizedAttr(ppd, keyword, spec, ll_CC);
+  else
+    locattr = _ppdLocalizedAttr(ppd, "Translation", keyword, ll_CC);
+
+  if (!locattr)
+    locattr = ppdFindAttr(ppd, keyword, spec);
+
+  return (locattr);
+}
+
+
 /*
  * 'ppdLocalizeIPPReason()' - Get the localized version of a cupsIPPReason
  *                            attribute.
@@ -666,5 +706,5 @@ ppd_ll_CC(char *ll_CC,                      /* O - Country-specific locale name */
 
 
 /*
- * End of "$Id: localize.c 7363 2008-03-03 22:19:24Z mike $".
+ * End of "$Id: localize.c 7679 2008-06-19 23:37:45Z mike $".
  */