5 - Localizing Printer Drivers

This chapter describes how to localize printer drivers for different languages and defaults.

Overview of the Localization Process

The PPD compiler provides localization of PPD files in different languages through message catalog files in the GNU gettext format. Each user text string and several key PPD attribute values such as LanguageVersion and LanguageEncoding are looked up in the corresponding message catalog and the translated text is substituted in the generated PPD files. One message catalog file can be used by multiple driver information files, and each file contains a single language translation.

The DDK provides a utility program to aid in the localization of drivers called ppdpo(1). In addition, the standard DDK installation includes basic localizations of all standard media sizes and options in English, French, German, Italian, Spanish, and Japanese.

Localizations are created using a few options to the PPD compiler which are covered later in this chapter.

The Message Catalog File Format

Each message catalog file can be edited with your favorite text editor and consists of one or more messages translated into a single language. Comment lines can be included using the # character, for example:

    # This is a comment

Each message is specified using a pair of directives: msgid and msgstr. The msgid string specifies the original (probably English) version of a string which is looked up when localizing a PPD file. The msgstr string contains the translated message. For example, the following message catalog translates the word "Yes" to French:

    msgid "Yes"
    msgstr "Oui"

Each message catalog will also contain two special entries for the LanguageVersion and LanguageEncoding attribute values. The standard msgid values are "English" and "ISOLatin1", respectively. They should be replaced with the Adobe-defined keywords for the language being localized and the character encoding, respectively. Table 5-1 lists the standard LanguageVersion, LanguageEncoding, and corresponding POSIX language abbreviation values that are supported.

The ppdpo Localization Utility

The ppdpo program creates or updates a message catalog file based upon one or more driver information files. New messages are added with the word "TRANSLATE" added to the front of the translation string to make locating new strings for translation easier. The program accepts the message catalog filename and one or more driver information files.

For example, run the following command to create a new German message catalog called de.po for all of the driver information files in the current directory:

    ppdpo -o de.po *.drv

If the file de.po already exists, ppdpo will update the contents of the file with any new messages that need to be translated.

Table 5-1, Supported LanguageVersion, LanguageEncoding, and POSIX language abbreviation values.
LanguageVersion LanguageEncoding POSIX
English ISOLatin1 en
Chinese None zh
Danish ISOLatin1 da
Dutch ISOLatin1 nl
Finnish ISOLatin1 fi
French ISOLatin1 fr
German ISOLatin1 de
Italian ISOLatin1 it
Japanese JIS83-RKSJ ja
Norwegian ISOLatin1 no
Portuguese ISOLatin1 pt
Russian None ru
Spanish ISOLatin1 es
Swedish ISOLatin1 sv
Turkish None tr
Note:

The LanguageVersion and LanguageEncoding strings are only used when creating single-language PPD files.

Globalized PPD files, which contain multiple languages in a single PPD file, always report "English" and "ISOLatin1" for the primary localization and provide the other languages using the UTF-8 encoding.

Using a Message Catalog with the PPD Compiler

Once you have created a message catalog, use the -c, -l, and -d options with ppdc to create PPD files in alternate languages. The -c option specifies the message catalog to use, the -l option specifies the standard DDK-supplied message catalog using the POSIX language abbreviation, and the -d option specifies the output directory. For example, use the following command to generate the German PPD files for the drivers listed in mydrivers.drv into the directory ppd/de:

    ppdc -l de -c de.po -d ppd/de mydrivers.drv

Using Multiple Message Catalogs

When you want to generate globalized PPD files containing multiple languages, start by listing any message catalog files in your driver information file using the #po directive:

    #po de "de.po"  // German
    #po es "es.po"  // Spanish
    #po fr "fr.po"  // French
    #po it "it.po"  // Italian
    #po ja "ja.po"  // Japanese

Then run the ppdc command, listing each language you want to include after the -l option. Each language name must be separated by a comma. For example, use the following command to generate globalized PPD files in English, German, Spanish, French, Italian, and Japanese for the drivers listed in mydrivers.drv into the directory ppd:

    ppdc -l en,de,es,fr,it,ja -d ppd mydrivers.drv

Merging Existing Single-Language PPD Files

The ppdmerge(1) utility allows you to merge existing single-language PPD files into a single globalized (multiple-language) PPD file. Simply provide the name of the PPD file you want to create or update with the -o option followed by a list of PPD files to merge. If the output file already exists, ppdmerge will load that PPD file first and then add the translations from the other PPD files to it.

For example, run the following command to merge all of the FooJet 2000 PPD files (each in their own language subdirectory and called foojet2k.ppd) into a single globalized PPD file called foojet2k.ppd:

    ppdmerge -o foojet2k.ppd */foojet2k.ppd

Similarly, run the following commands to incrementally add the French and Italian translations to the English PPD file:

    ppdmerge -o foojet2k.ppd fr/foojet2k.ppd
    ppdmerge -o foojet2k.ppd it/foojet2k.ppd