Miva Merchant: E-commerce Solutions to Grow Online
spacer gif

19. Localization


The localized tags allow you to design Miva Script programs that can display in various languages. In this way your programs can become truly international!

Language Identifiers

There are two language identifiers (current and default) that are set using two built-in functions:
miva_setlanguage (language)
sets the current language.
miva_setdefaultlanguage (language)
sets the current language.

language has two components:

(language-country code)

The default is "en-US" for English-United States. For example:
miva_setlanguage (`de-DE')
sets language to German.
miva_setlanguage (`en-US')
sets language to US English.

Retrieve Settings:

The following system variables retrieve the language settings:
. s.miva_language
retrieves the current language setting.
. s.miva_defaultlanguage
retrieves the current default language setting.

Localization Block

Starts the localization process. The tag can create a variable for output.

<MvLOCALIZED ID="xxx" NAME="l.output" STANDARDOUTPUTLEVEL="">
...
</MvLOCALIZED>
ID
For informational purposes and is not currently used by Miva Script.
NAME
Optional. If specified, the output from the tag is stored in the variable named by this attribute instead of being sent to the browser.
STANDARDOUTPUTLEVEL
The possible values are:
. html: HTML tags will be passed to the browser
. text: text will be passed to the browser
. text, html or html, text: both text and HTML tags will be passed to the browser (same as the default)
. null string: neither text nor HTML tags will be passed to the browser. Note that a STANDARDOUTPUTLEVEL value consisting of any arbitrary string (such as none) is equivalent to the null string.

Localized Text

<MvLOCALIZED-TEXT LANGUAGE="language_id">
...
</MvLOCALIZED-TEXT>

Defines the text for the language specified by the LANGUAGE attribute. HTML is allowed, but no Miva tags may exist between the <MvLOCALIZED-TEXT> and
</MvLOCALIZED-TEXT> tags.

Examples:

Displays the text in the language that has been previously set.

<MvLOCALIZED>
<MvLOCALIZED-TEXT LANGUAGE = "de-DE">
Dies ist das deutsche.
</MvLOCALIZED-TEXT>
</MvLOCALIZED>
<MvLOCALIZED>
<MvLOCALIZED-TEXT LANGUAGE = "en-US">
This is the english.
</MvLOCALIZED-TEXT>

Localized Token

Creates a "token" (or representation) which can then be displayed in localized text. Must be inside <MvLocalized> and must precede any <MvLocalized-Text> blocks that use the token.

<MvLOCALIZED-TOKEN NAME="token" VALUE="xxx">
NAME
name of the token.
VALUE
value of the token.

Example (localized token):

<MvLOCALIZED NAME = "g.Message" ID = "MER-ADM-00224">
<MvLOCALIZED-TOKEN NAME = "store_name" VALUE = "{encodeentities(Stores.d.name)}">
<MvLOCALIZED-TEXT LANGUAGE = "en-US">Database Files for Store '%store_name%' Packed.</MvLOCALIZED-TEXT>
<MvLOCALIZED-TEXT LANGUAGE = "de-DE">Datenbankdateien f¸r Laden '%store_name%' gepackt.</MvLOCALIZED-TEXT>
</MvLOCALIZED>

Localization Sample

<FORM METHOD = "GET">
<SELECT NAME = "Language">
<OPTION VALUE = "en-US">English</OPTION>
<OPTION VALUE = "de-DE">German</OPTION>
</SELECT>
<INPUT TYPE = "submit">
</FORM>
<MvIF EXPR = "{ len( g.Language ) }">
<MvEVAL EXPR = "{ miva_setlanguage( g.Language ) }">
</MvIF>
<MvLOCALIZED>
<MvLOCALIZED-TEXT LANGUAGE = "en-US">
This is the english.
</MvLOCALIZED-TEXT>
<MvLOCALIZED-TEXT LANGUAGE = "de-DE">
Dies ist das deutsche.
</MvLOCALIZED-TEXT>
</MvLOCALIZED>