Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Globalized PPD Strings not showing in web interface #1913

Closed
michaelrsweet opened this issue Aug 15, 2006 · 2 comments
Closed

Globalized PPD Strings not showing in web interface #1913

michaelrsweet opened this issue Aug 15, 2006 · 2 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.2.2
CUPS.org User: joshmathis

I have added two translations to my ppd (French and German) according to the documentation on the site (http://www.cups.org/documentation.php/spec-ppd.html). cupstestppd says it is ok. However, when I go to the web interface, all of my printer options remain in English.

The localhost:631 homepage is localized in my desired language. However, when I go to any other page, it is either all in English or mixed languages. Example: On the home page, the top menu is completely localized, but when I click "Printers", the top menu changes back to English.

I changed my loglevel to debug and tail'd the log file while browsing
the web interface. It always shows locale=(my desired target code).

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet
Copy link
Collaborator Author

"ppdlocalize.patch":

Index: localize.c

--- localize.c (revision 5823)
+++ localize.c (working copy)
@@ -80,6 +80,8 @@

  • Range check input...
    */
  • DEBUG_printf(("ppdLocalize(ppd=%p)\n", ppd));

if (!ppd)
return (-1);

@@ -93,6 +95,9 @@
strlcpy(ll_CC, lang->language, sizeof(ll_CC));
strlcpy(ll, lang->language, sizeof(ll));

  • DEBUG_printf((" lang->language="%s", ll="%s", ll_CC="%s"...\n",

  •            lang->language, ll, ll_CC));
    

    /*

    • Now lookup all of the groups, options, choices, etc.
      /
      @@ -165,17 +170,29 @@
      ppd_attr_t *attr; /
      Current attribute */
  • DEBUG_printf(("ppd_text(ppd=%p, keyword="%s", spec="%s", "

  •            "ll_CC=\"%s\", ll=\"%s\")\n",
    
  •            ppd, keyword, spec, ll_CC, ll));
    

    /*

    • Look for Keyword.ll_CC, then Keyword.ll...
      */
  • snprintf(lkeyword, sizeof(lkeyword), "%s.%s", keyword, ll_CC);

  • snprintf(lkeyword, sizeof(lkeyword), "%s.%s", ll_CC, keyword);
    if ((attr = ppdFindAttr(ppd, lkeyword, spec)) == NULL)
    {

  • snprintf(lkeyword, sizeof(lkeyword), "%s.%s", keyword, ll);

  • snprintf(lkeyword, sizeof(lkeyword), "%s.%s", ll, keyword);
    attr = ppdFindAttr(ppd, lkeyword, spec);
    }

+#ifdef DEBUG

  • if (attr)
  • printf(" *%s %s/%s: "%s"\n", attr->name, attr->spec, attr->text,
  •       attr->value ? attr->value : "");
    
  • else
  • puts(" NOT FOUND");
    +#endif /* DEBUG _/

/_

  • Return text if we find it...
    */
    Index: ppd.c

    --- ppd.c (revision 5823)
    +++ ppd.c (working copy)
    @@ -2037,10 +2037,8 @@

if ((ret = strcasecmp(a->name, b->name)) != 0)
return (ret);

  • else if (a->spec[0] && b->spec[0])
  • return (strcasecmp(a->spec, b->spec));
    else
  • return (0);
  • return (strcasecmp(a->spec, b->spec));
    }

Index: attr.c

--- attr.c (revision 5823)
+++ attr.c (working copy)
@@ -44,14 +44,19 @@

-ppd_attr_t * /* O - Attribute or NULL if not found /
-ppdFindAttr(ppd_file_t *ppd, /
I - PPD file data */

  •        const char _name,  /_ I - Attribute name */
    
  •        const char _spec)  /_ I - Specifier string or NULL _/
    

    +ppd_attr_t * /_ O - Attribute or NULL if not found /
    +ppdFindAttr(ppd_file_t *ppd, /
    I - PPD file data */

  •        const char _name,      /_ I - Attribute name */
    
  •        const char _spec)      /_ I - Specifier string or NULL */
    

    {

  • ppd_attr_t key; /* Search key */

  • ppd_attr_t key, /* Search key */

  •   _attr;          /_ Current attribute */
    
  • int diff; /* Current difference */

  • DEBUG_printf(("ppdFindAttr(ppd=%p, name="%s", spec="%s")\n", ppd,

  •            name ? name : "(null)", spec ? spec : "(null)"));
    

    /*

    • Range check input...
      */
      @@ -72,7 +77,36 @@
    • Return the first matching attribute, if any...
      */
  • return ((ppd_attr_t *)cupsArrayFind(ppd->sorted_attrs, &key));

  • if ((attr = (ppd_attr_t *)cupsArrayFind(ppd->sorted_attrs, &key)) != NULL)

  • return (attr);

  • else if (spec)

  • return (NULL);

  • /*
  • * No match found, loop through the sorted attributes to see if we can
  • * find a "wildcard" match for the attribute...
  • */
  • for (attr = (ppd_attr_t *)cupsArrayFirst(ppd->sorted_attrs);
  •   attr;
    
  •   attr = (ppd_attr_t *)cupsArrayFirst(ppd->sorted_attrs))
    
  • {
  • if ((diff = strcasecmp(attr->name, name)) == 0)
  •  break;
    
  • if (diff > 0)
  • {
  • /*
    
  •  \* All remaining attributes are > than the one we are trying to find...
    
  •  */
    
  •  cupsArrayIndex(ppd->sorted_attrs, cupsArrayCount(ppd->sorted_attrs));
    
  •  return (NULL);
    
  • }
  • }
  • return (attr);
    }

Index: testppd.c

--- testppd.c (revision 5823)
+++ testppd.c (working copy)
@@ -192,10 +192,18 @@
else
{
int i, j, k; /* Looping vars */

  •  ppd_attr_t   _attr;      /_ Current attribute _/
    

    ppd_group_t *group; /_ Option group /
    ppd_option_t *option; /
    Option */

  •  char     lang[255];  /* LANG environment variable */
    
  •  if (argc > 2)
    
  •  {
    
  •    snprintf(lang, sizeof(lang), "LANG=%s", argv[2]);
    
  • putenv(lang);

  •  }
    
    • ppdLocalize(ppd);

      for (i = ppd->num_groups, group = ppd->groups;
      @@ -203,7 +211,7 @@
      i --, group ++)
      {
      printf("%s (%s):\n", group->name, group->text);

    for (j = group->num_options, option = group->options;
    j > 0;
    j --, option ++)
    @@ -215,6 +223,14 @@
    option->choices[k].text);
    }
    }
    +

  •  puts("Attributes:");
    
  •  for (attr = (ppd_attr_t *)cupsArrayFirst(ppd->sorted_attrs);
    
  •       attr;
    
  •  attr = (ppd_attr_t *)cupsArrayNext(ppd->sorted_attrs))
    
  •    printf("    *%s %s/%s: \"%s\"\n", attr->name, attr->spec,
    
  •      attr->text, attr->value ? attr->value : "");
    

    }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant