* information.
*/
-/*
- * Include necessary headers...
- */
-
#include "cups-private.h"
#include "ppd-private.h"
#include "debug-internal.h"
#include <math.h>
+#include <ctype.h>
/*
static const char *ppd_inputslot_for_keyword(_ppd_cache_t *pc, const char *keyword);
static void ppd_put_strings(cups_file_t *fp, cups_lang_t *langs, const char *ppd_option, const char *ppd_choice, const char *pwg_msgid);
static void pwg_add_finishing(cups_array_t *finishings, ipp_finishings_t template, const char *name, const char *value);
-static void pwg_add_message(cups_array_t *a, const char *msg, const char *str);
static int pwg_compare_finishings(_pwg_finishings_t *a, _pwg_finishings_t *b, void *data);
static int pwg_compare_sizes(cups_size_t *a, cups_size_t *b, void *data);
static cups_size_t *pwg_copy_size(cups_size_t *size, void *data);
*/
_ppd_cache_t * /* O - PPD cache and mapping data */
-_ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */
+_ppdCacheCreateWithPPD(
+ cups_lang_t *langs, /* I - Languages to load */
+ ppd_file_t *ppd) /* I - PPD file */
{
int i, j, k; /* Looping vars */
_ppd_cache_t *pc; /* PWG mapping data */
const char *filter; /* Current filter */
_pwg_finishings_t *finishings; /* Current finishings value */
char msg_id[256]; /* Message identifier */
+ cups_lang_t *lang; /* Current language */
+ _cups_message_t msg; /* Message */
DEBUG_printf("_ppdCacheCreateWithPPD(ppd=%p)", (void *)ppd);
goto create_error;
}
- pc->strings = _cupsMessageNew(NULL);
-
/*
* Copy and convert size data...
*/
*/
snprintf(msg_id, sizeof(msg_id), "media-source.%s", pwg_name);
- pwg_add_message(pc->strings, msg_id, choice->text);
+ msg.msg = msg_id;
+
+ for (lang = langs; lang; lang = lang->next)
+ {
+ // See if the string is already localized...
+ if (cupsArrayFind(lang->strings, &msg))
+ continue; // Yes
+
+ // Otherwise add the text...
+ if (!strcmp(lang->language, "en"))
+ {
+ // English
+ msg.str = choice->text;
+ }
+ else
+ {
+ // Other languauge...
+ snprintf(ppd_name, sizeof(ppd_name), "%s.InputSlot", lang->language);
+ if ((ppd_attr = ppdFindAttr(ppd, ppd_name, choice->choice)) != NULL)
+ msg.str = ppd_attr->text;
+ else
+ continue;
+ }
+
+ cupsArrayAdd(lang->strings, &msg);
+ }
}
}
}
}
+
/*
* Add localized text for PWG keyword to message catalog...
*/
snprintf(msg_id, sizeof(msg_id), "media-type.%s", map->pwg);
- pwg_add_message(pc->strings, msg_id, choice->text);
+ msg.msg = msg_id;
+
+ for (lang = langs; lang; lang = lang->next)
+ {
+ // See if the string is already localized...
+ if (cupsArrayFind(lang->strings, &msg))
+ continue; // Yes
+
+ // Otherwise add the text...
+ if (!strcmp(lang->language, "en"))
+ {
+ // English
+ msg.str = choice->text;
+ }
+ else
+ {
+ // Other languauge...
+ snprintf(ppd_name, sizeof(ppd_name), "%s.MediaType", lang->language);
+ if ((ppd_attr = ppdFindAttr(ppd, ppd_name, choice->choice)) != NULL)
+ msg.str = ppd_attr->text;
+ else
+ continue;
+ }
+
+ cupsArrayAdd(lang->strings, &msg);
+ }
}
}
map->pwg = strdup(pwg_keyword);
map->ppd = strdup(choice->choice);
+
/*
* Add localized text for PWG keyword to message catalog...
*/
- snprintf(msg_id, sizeof(msg_id), "output-bin.%s", pwg_keyword);
- pwg_add_message(pc->strings, msg_id, choice->text);
+ snprintf(msg_id, sizeof(msg_id), "output-bin.%s", pwg_name);
+ msg.msg = msg_id;
+
+ for (lang = langs; lang; lang = lang->next)
+ {
+ // See if the string is already localized...
+ if (cupsArrayFind(lang->strings, &msg))
+ continue; // Yes
+
+ // Otherwise add the text...
+ if (!strcmp(lang->language, "en"))
+ {
+ // English
+ msg.str = choice->text;
+ }
+ else
+ {
+ // Other languauge...
+ snprintf(ppd_name, sizeof(ppd_name), "%s.OutputBin", lang->language);
+ if ((ppd_attr = ppdFindAttr(ppd, ppd_name, choice->choice)) != NULL)
+ msg.str = ppd_attr->text;
+ else
+ continue;
+ }
+
+ cupsArrayAdd(lang->strings, &msg);
+ }
}
}
do
{
+#if 0
/*
* Add localized text for PWG keyword to message catalog...
*/
snprintf(msg_id, sizeof(msg_id), "preset-name.%s", ppd_attr->spec);
pwg_add_message(pc->strings, msg_id, ppd_attr->text);
+#endif // 0
/*
* Get the options for this preset...
*/
snprintf(msg_id, sizeof(msg_id), "finishing-template.%s", choice->choice);
- pwg_add_message(pc->strings, msg_id, choice->text);
+ msg.msg = msg_id;
+
+ for (lang = langs; lang; lang = lang->next)
+ {
+ // See if the string is already localized...
+ if (cupsArrayFind(lang->strings, &msg))
+ continue; // Yes
+
+ // Otherwise add the text...
+ if (!strcmp(lang->language, "en"))
+ {
+ // English
+ msg.str = choice->text;
+ }
+ else
+ {
+ // Other languauge...
+ snprintf(ppd_name, sizeof(ppd_name), "%s.cupsFinishingTemplate", lang->language);
+ if ((ppd_attr = ppdFindAttr(ppd, ppd_name, choice->choice)) != NULL)
+ msg.str = ppd_attr->text;
+ else
+ continue;
+ }
+
+ cupsArrayAdd(lang->strings, &msg);
+ }
}
}
cupsArrayDelete(pc->support_files);
- cupsArrayDelete(pc->strings);
-
free(pc);
}
return ("");
cupsCopyString(buffer, msgptr, bufsize);
- buffer[0] = toupper(buffer[0] & 255);
+ buffer[0] = (char)toupper(buffer[0] & 255);
for (bufptr = buffer + 1; *bufptr; bufptr ++)
{
if (*bufptr == '-')
{
*bufptr = ' ';
- bufptr[1] = toupper(bufptr[1] & 255);
+ bufptr[1] = (char)toupper(bufptr[1] & 255);
}
}
}
-/*
- * 'pwg_add_message()' - Add a message to the PPD cached strings.
- */
-
-static void
-pwg_add_message(cups_array_t *a, /* I - Message catalog */
- const char *msg, /* I - Message identifier */
- const char *str) /* I - Localized string */
-{
- _cups_message_t *m; /* New message */
-
-
- if ((m = calloc(1, sizeof(_cups_message_t))) != NULL)
- {
- m->msg = strdup(msg);
- m->str = strdup(str);
- cupsArrayAdd(a, m);
- }
-}
-
-
/*
* 'pwg_compare_finishings()' - Compare two finishings values.
*/