MiniVend Locale Settings

### Index Up << >>

## MiniVend Locale Settings

The `Locale` directive has many possible settings, allowing complete internationalization of page sets and currencies. The `Locale` directive is defined in a series of key/value pairs, with a key (which contains word characters only) followed by a value. The value should be surrounded with double quotes if it contains whitespace. In this example, the key is `Value setting`.

        Locale fr_FR "Value setting" "Configuration de valeur"
        Locale de_DE "Value setting" Werteinstellung

When accessed via the special tag `[L]Value setting[/L]`, the value `Configuration de valeur` will be displayed only if the locale is set to `fr_FR`. If the locale is set to `de_DE`, the string `Werteinstellung` will be displayed. If it is neither, the default value of `Value setting` will be displayed.

The `[L]` and `[/L]` must be capitalized -- this is done for speed of processing as well as easy differentiation in text.

Another, perhaps better, way to do this is right in the page. The `[LC]` ... `[/LC]` pragma pair allows you to specify locale-dependent text.

      [LC]
                This is the default text.
        [fr_FR] Text for the fr_FR locale. [/fr_FR]
        [de_DE] Text for the de_DE locale. [/de_DE]
      [/LC]

Or you can place an entire new page in place of the default one if you define the locale key. When locale is in force, and a key named HTMLsuffix is set to the locale, MiniVend first looks for a page with a suffix corresponding to the locale. For example:

        <A HREF="[area index]">Catalog home page</A>

If a page index.html exists, it will be the default. If the current locale is `fr_FR`, a page ``index.fr_FR'' exists, and you have in Locale:

        Locale fr_FR HTMLsuffix  fr_FR

then the `.fr_FR` page will be used instead of the `.html` page.

For longer series of strings, the configuration file recognizes:

        Locale fr_FR <<EOF
        {
            "Value setting",
            "Configuration de valeur",

            "Search",
            "Recherche"
        }
        EOF

The above sets two string substitutions. As long as this is valid Perl syntax describing a series of settings, the text will be matched. It can contain any arbitrary set of characters that don't contain `[L]` and `[/L]`. If using double quotes, string literals like \n and \t are recognized.

You can also use a database to set locale information. It is added to any in the catalog.cfg file, and values in it will overwrite previous settings. See LocaleDatabase.

The `[L]default text[/L]` is set before any other page processing. It is equivalent to the characters ``default text'' or the appropriate Locale translation for all intents and purposes. Minivend tags and Variable values can be embedded.

Since the `[L] message [/L]` substitution is done before any tag processing, you cannot do `[L][item-data table field][/L]` and expect success. There is an add-on `[loc] message [/loc]` UserTag supplied with the distribution beginning at V3.09. It does the same thing as `[L] [/L]` except after all tag substitution is done. See minivend.cfg.dist for the definition.

You will need to be quite careful in editing pages with localization information. Changing even one character of the message will change the key value and invalidate the message for other languages. To prevent this, you can instead use:

        [L key]The default.[/L]

The key `msg_key` will then be used to index the message. This may be preferable for many applications.

A `localize` script is included with minivend. It will parse files included on the command line and produce output that can be easily edited to produce localized information. Given an existing file, it will merge new information where appropriate.

### Index Up << >>