MCPcopy Create free account
hub / github.com/OpenPrinting/cups / ppdLocalize

Function ppdLocalize

cups/ppd-localize.c:40–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38 */
39
40int /* O - 0 on success, -1 on error */
41ppdLocalize(ppd_file_t *ppd) /* I - PPD file */
42{
43 int i, j, k; /* Looping vars */
44 ppd_group_t *group; /* Current group */
45 ppd_option_t *option; /* Current option */
46 ppd_choice_t *choice; /* Current choice */
47 ppd_coption_t *coption; /* Current custom option */
48 ppd_cparam_t *cparam; /* Current custom parameter */
49 ppd_attr_t *attr, /* Current attribute */
50 *locattr; /* Localized attribute */
51 char ckeyword[PPD_MAX_NAME], /* Custom keyword */
52 ll_CC[6]; /* Language + country locale */
53
54
55 /*
56 * Range check input...
57 */
58
59 DEBUG_printf(("ppdLocalize(ppd=%p)", ppd));
60
61 if (!ppd)
62 return (-1);
63
64 /*
65 * Get the default language...
66 */
67
68 ppd_ll_CC(ll_CC, sizeof(ll_CC));
69
70 /*
71 * Now lookup all of the groups, options, choices, etc.
72 */
73
74 for (i = ppd->num_groups, group = ppd->groups; i > 0; i --, group ++)
75 {
76 if ((locattr = _ppdLocalizedAttr(ppd, "Translation", group->name,
77 ll_CC)) != NULL)
78 strlcpy(group->text, locattr->text, sizeof(group->text));
79
80 for (j = group->num_options, option = group->options; j > 0; j --, option ++)
81 {
82 if ((locattr = _ppdLocalizedAttr(ppd, "Translation", option->keyword,
83 ll_CC)) != NULL)
84 strlcpy(option->text, locattr->text, sizeof(option->text));
85
86 for (k = option->num_choices, choice = option->choices;
87 k > 0;
88 k --, choice ++)
89 {
90 if (strcmp(choice->choice, "Custom") ||
91 !ppdFindCustomOption(ppd, option->keyword))
92 locattr = _ppdLocalizedAttr(ppd, option->keyword, choice->choice,
93 ll_CC);
94 else
95 {
96 snprintf(ckeyword, sizeof(ckeyword), "Custom%s", option->keyword);
97

Callers 3

do_set_optionsFunction · 0.85
mainFunction · 0.85
show_ppdFunction · 0.85

Calls 9

ppd_ll_CCFunction · 0.85
_ppdLocalizedAttrFunction · 0.85
ppdFindCustomOptionFunction · 0.85
cupsArrayFirstFunction · 0.85
cupsArrayNextFunction · 0.85
ppdFindAttrFunction · 0.85
ppdFindNextAttrFunction · 0.85
cupsArraySaveFunction · 0.85
cupsArrayRestoreFunction · 0.85

Tested by 2

mainFunction · 0.68
show_ppdFunction · 0.68