]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/localize.c
Import changes from CUPS 1.4svn-r8704.
[thirdparty/cups.git] / cups / localize.c
index 19a03e26c7a668813ec435e7cf55a54feb723878..94a3ffc7a0f2b7ceb10a34ba3acba329d7f9cf7f 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   PPD localization routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2009 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -52,7 +52,7 @@
  * Local functions...
  */
 
-static void            ppd_ll_CC(char *ll_CC, int ll_CC_size);
+static cups_lang_t     *ppd_ll_CC(char *ll_CC, int ll_CC_size);
 
 
 /*
@@ -84,7 +84,7 @@ ppdLocalize(ppd_file_t *ppd)          /* I - PPD file */
   * Range check input...
   */
 
-  DEBUG_printf(("ppdLocalize(ppd=%p)\n", ppd));
+  DEBUG_printf(("ppdLocalize(ppd=%p)", ppd));
 
   if (!ppd)
     return (-1);
@@ -115,7 +115,8 @@ ppdLocalize(ppd_file_t *ppd)                /* I - PPD file */
            k > 0;
           k --, choice ++)
       {
-        if (strcmp(choice->choice, "Custom"))
+        if (strcmp(choice->choice, "Custom") ||
+           !ppdFindCustomOption(ppd, option->keyword))
          locattr = _ppdLocalizedAttr(ppd, option->keyword, choice->choice,
                                      ll_CC);
        else
@@ -257,6 +258,7 @@ ppdLocalizeIPPReason(
     char       *buffer,                        /* I - Value buffer */
     size_t     bufsize)                        /* I - Size of value buffer */
 {
+  cups_lang_t  *lang;                  /* Current language */
   ppd_attr_t   *locattr;               /* Localized attribute */
   char         ll_CC[6],               /* Language + country locale */
                *bufptr,                /* Pointer into buffer */
@@ -281,7 +283,7 @@ ppdLocalizeIPPReason(
   * Get the default language...
   */
 
-  ppd_ll_CC(ll_CC, sizeof(ll_CC));
+  lang = ppd_ll_CC(ll_CC, sizeof(ll_CC));
 
  /*
   * Find the localized attribute...
@@ -292,7 +294,75 @@ ppdLocalizeIPPReason(
     locattr = ppdFindAttr(ppd, "cupsIPPReason", reason);
 
   if (!locattr)
+  {
+    if (lang && (!scheme || !strcmp(scheme, "text")))
+    {
+     /*
+      * Try to localize a standard printer-state-reason keyword...
+      */
+
+      const char *message = NULL;      /* Localized message */
+
+
+      if (!strncmp(reason, "media-needed", 12))
+        message = _("Media tray needs to be filled.");
+      else if (!strncmp(reason, "media-jam", 9))
+        message = _("Media jam!");
+      else if (!strncmp(reason, "offline", 7) ||
+              !strncmp(reason, "shutdown", 8))
+        message = _("Printer offline.");
+      else if (!strncmp(reason, "toner-low", 9))
+        message = _("Toner low.");
+      else if (!strncmp(reason, "toner-empty", 11))
+        message = _("Out of toner!");
+      else if (!strncmp(reason, "cover-open", 10))
+        message = _("Cover open.");
+      else if (!strncmp(reason, "interlock-open", 14))
+        message = _("Interlock open.");
+      else if (!strncmp(reason, "door-open", 9))
+        message = _("Door open.");
+      else if (!strncmp(reason, "input-tray-missing", 18))
+        message = _("Media tray missing!");
+      else if (!strncmp(reason, "media-low", 9))
+        message = _("Media tray almost empty.");
+      else if (!strncmp(reason, "media-empty", 11))
+        message = _("Media tray empty!");
+      else if (!strncmp(reason, "output-tray-missing", 19))
+        message = _("Output tray missing!");
+      else if (!strncmp(reason, "output-area-almost-full", 23))
+        message = _("Output bin almost full.");
+      else if (!strncmp(reason, "output-area-full", 16))
+        message = _("Output bin full!");
+      else if (!strncmp(reason, "marker-supply-low", 17))
+        message = _("Ink/toner almost empty.");
+      else if (!strncmp(reason, "marker-supply-empty", 19))
+        message = _("Ink/toner empty!");
+      else if (!strncmp(reason, "marker-waste-almost-full", 24))
+        message = _("Ink/toner waste bin almost full.");
+      else if (!strncmp(reason, "marker-waste-full", 17))
+        message = _("Ink/toner waste bin full!");
+      else if (!strncmp(reason, "fuser-over-temp", 15))
+        message = _("Fuser temperature high!");
+      else if (!strncmp(reason, "fuser-under-temp", 16))
+        message = _("Fuser temperature low!");
+      else if (!strncmp(reason, "opc-near-eol", 12))
+        message = _("OPC almost at end-of-life.");
+      else if (!strncmp(reason, "opc-life-over", 13))
+        message = _("OPC at end-of-life!");
+      else if (!strncmp(reason, "developer-low", 13))
+        message = _("Developer almost empty.");
+      else if (!strncmp(reason, "developer-empty", 15))
+        message = _("Developer empty!");
+
+      if (message)
+      {
+        strlcpy(buffer, _cupsLangString(lang, message), bufsize);
+       return (buffer);
+      }
+    }
+
     return (NULL);
+  }
 
  /*
   * Now find the value we need...
@@ -431,7 +501,7 @@ ppdLocalizeIPPReason(
  * text from the attribute value. If no localized text for the requested
  * name can be found, @code NULL@ is returned.
  *
- * @since CUPS 1.4@
+ * @since CUPS 1.4/Mac OS X 10.6@
  */
 
 const char *                           /* O - Value or @code NULL@ if not found */
@@ -601,8 +671,8 @@ _ppdLocalizedAttr(ppd_file_t *ppd,  /* I - PPD file */
   ppd_attr_t   *attr;                  /* Current attribute */
 
 
-  DEBUG_printf(("_ppdLocalizedAttr(ppd=%p, keyword=\"%s\", spec=\"%s\", "
-                "ll_CC=\"%s\")\n", ppd, keyword, spec, ll_CC));
+  DEBUG_printf(("4_ppdLocalizedAttr(ppd=%p, keyword=\"%s\", spec=\"%s\", "
+                "ll_CC=\"%s\")", ppd, keyword, spec, ll_CC));
 
  /*
   * Look for Keyword.ll_CC, then Keyword.ll...
@@ -644,10 +714,10 @@ _ppdLocalizedAttr(ppd_file_t *ppd,        /* I - PPD file */
 
 #ifdef DEBUG
   if (attr)
-    DEBUG_printf(("_ppdLocalizedAttr: *%s %s/%s: \"%s\"\n", attr->name,
+    DEBUG_printf(("5_ppdLocalizedAttr: *%s %s/%s: \"%s\"\n", attr->name,
                   attr->spec, attr->text, attr->value ? attr->value : ""));
   else
-    DEBUG_puts("_ppdLocalizedAttr: NOT FOUND");
+    DEBUG_puts("5_ppdLocalizedAttr: NOT FOUND");
 #endif /* DEBUG */
 
   return (attr);
@@ -658,7 +728,7 @@ _ppdLocalizedAttr(ppd_file_t *ppd,  /* I - PPD file */
  * 'ppd_ll_CC()' - Get the current locale names.
  */
 
-static void
+static cups_lang_t *                   /* O - Current language */
 ppd_ll_CC(char *ll_CC,                 /* O - Country-specific locale name */
           int  ll_CC_size)             /* I - Size of country-specific name */
 {
@@ -672,7 +742,7 @@ ppd_ll_CC(char *ll_CC,                      /* O - Country-specific locale name */
   if ((lang = cupsLangDefault()) == NULL)
   {
     strlcpy(ll_CC, "en_US", ll_CC_size);
-    return;
+    return (NULL);
   }
 
  /*
@@ -700,8 +770,9 @@ ppd_ll_CC(char *ll_CC,                      /* O - Country-specific locale name */
       strlcpy(ll_CC, "zh_CN", ll_CC_size);
   }
 
-  DEBUG_printf(("ppd_ll_CC: lang->language=\"%s\", ll_CC=\"%s\"...\n",
+  DEBUG_printf(("8ppd_ll_CC: lang->language=\"%s\", ll_CC=\"%s\"...",
                 lang->language, ll_CC));
+  return (lang);
 }