| 591 | */ |
| 592 | |
| 593 | ppd_attr_t * /* O - Localized attribute or NULL */ |
| 594 | _ppdLocalizedAttr(ppd_file_t *ppd, /* I - PPD file */ |
| 595 | const char *keyword, /* I - Main keyword */ |
| 596 | const char *spec, /* I - Option keyword */ |
| 597 | const char *ll_CC) /* I - Language + country locale */ |
| 598 | { |
| 599 | char lkeyword[PPD_MAX_NAME]; /* Localization keyword */ |
| 600 | ppd_attr_t *attr; /* Current attribute */ |
| 601 | |
| 602 | |
| 603 | DEBUG_printf(("4_ppdLocalizedAttr(ppd=%p, keyword=\"%s\", spec=\"%s\", " |
| 604 | "ll_CC=\"%s\")", ppd, keyword, spec, ll_CC)); |
| 605 | |
| 606 | /* |
| 607 | * Look for Keyword.ll_CC, then Keyword.ll... |
| 608 | */ |
| 609 | |
| 610 | snprintf(lkeyword, sizeof(lkeyword), "%s.%s", ll_CC, keyword); |
| 611 | if ((attr = ppdFindAttr(ppd, lkeyword, spec)) == NULL) |
| 612 | { |
| 613 | /* |
| 614 | * <rdar://problem/22130168> |
| 615 | * |
| 616 | * Multiple locales need special handling... Sigh... |
| 617 | */ |
| 618 | |
| 619 | if (!strcmp(ll_CC, "zh_HK")) |
| 620 | { |
| 621 | snprintf(lkeyword, sizeof(lkeyword), "zh_TW.%s", keyword); |
| 622 | attr = ppdFindAttr(ppd, lkeyword, spec); |
| 623 | } |
| 624 | |
| 625 | if (!attr) |
| 626 | { |
| 627 | snprintf(lkeyword, sizeof(lkeyword), "%2.2s.%s", ll_CC, keyword); |
| 628 | attr = ppdFindAttr(ppd, lkeyword, spec); |
| 629 | } |
| 630 | |
| 631 | if (!attr) |
| 632 | { |
| 633 | if (!strncmp(ll_CC, "ja", 2)) |
| 634 | { |
| 635 | /* |
| 636 | * Due to a bug in the CUPS DDK 1.1.0 ppdmerge program, Japanese |
| 637 | * PPD files were incorrectly assigned "jp" as the locale name |
| 638 | * instead of "ja". Support both the old (incorrect) and new |
| 639 | * locale names for Japanese... |
| 640 | */ |
| 641 | |
| 642 | snprintf(lkeyword, sizeof(lkeyword), "jp.%s", keyword); |
| 643 | attr = ppdFindAttr(ppd, lkeyword, spec); |
| 644 | } |
| 645 | else if (!strncmp(ll_CC, "nb", 2)) |
| 646 | { |
| 647 | /* |
| 648 | * Norway has two languages, "Bokmal" (the primary one) |
| 649 | * and "Nynorsk" (new Norwegian); this code maps from the (currently) |
| 650 | * recommended "nb" to the previously recommended "no"... |
no test coverage detected