Skip to content

MvLOCALIZED#


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. Starts the localization process. The tag can create a variable for output.

Syntax
<MvLOCALIZED NAME = "string: {  expression } | literal"
             ID = "string: {  expression } | literal"
             STANDARDOUTPUTLEVEL = "keyword">

<MvLOCALIZED-TOKEN 
             NAME = "string: {  expression } | literal"
             VALUE = "{ expression } | literal">

<MvLOCALIZED-TEXT 
             LANGUAGE = "string: {  expression } | literal language_id"> 
</MvLOCALIZED>
Localization allows you to embed language-specific prompts in your scripts.

Attributes#

Attribute Description
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.
ID Optional. For informational purposes and is not currently used by Miva Script.
STANDARDOUTPUTLEVEL Optional keywords: html, text, null string. Specifies what displays in browser.
- html: HTML is output to the browser. Default.
- text: text (non html) is output to the browser. Default.
- null string: will cause Miva Script to suppress output.

Language Identifiers#

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

The default is en-US for English-United States.

This example sets language to German
<MvASSIGN NAME="l.ok" VALUE="{ miva_setlanguage ('de-DE') }">

The system variable s.miva_defaultlanguage retrieves the current language settings.

Example:

s.miva_defaultlanguage
The current language is <MvEVAL EXPR="{ s.miva_defaultlanguage }">

Localization Blocks#

The <MvLOCALIZED> tag starts the localization process. The tag can create a variable for output.

Example:

MvLOCALIZED
<MvLOCALIZED NAME="l.output" ID="001"  STANDARDOUTPUTLEVEL="">
...
</MvLOCALIZED>

Localized 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. You can include localized text for as many languages as you like. This example displays the text for the previously set language.

<MvLOCALIZED-TEXT LANGUAGE = "en-US">Category: </MvLOCALIZED-TEXT>
<MvLOCALIZED-TEXT LANGUAGE = "de-DE">Kategorie: </MvLOCALIZED-TEXT>

Localized Token#

Creates a “token” (or representation) which can then be displayed in localized text. Must be inside the <MvLOCALIZED> block and must precede any <MvLOCALIZED-TEXT> blocks that use the token. You can include localized text for as many languages as you like. This example displays the text for the previously set language.

<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>

Example#

In this example, a user selects a language from a form. When submitted, the default language is set and a message is displayed in the correct language.

<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>