This tag enables you to define localized text (i.e. translated into different languages) for your templates. You use this tag to define the translations and the [[localize]] function tags to display that text, based on the currently selected culture in DNN. There can be only one <xmod:localization> tag in your template, but you can have multiple [[localize]] functions. When you have multiple languages installed in DNN, users can choose which language they'd prefer to view the site in. When they select a language, your XMod templates can switch to that language as well. Please note that only static text can be localized. The data entered via XMod forms cannot be localized.
Here's an example of what the tag looks like:
<xmod:localization>
<culture name="es-ES">
<data name="Name">Su Nombre</data>
<data name="Address">Su Dirección</data>
</culture>
<culture name="fr-FR">
<data name="Name">Votre Nom</data>
<data name="Address">Votre Adresse</data>
</culture>
<culture name="nl-NL">
<data name="Name">uw naam</data>
<data name="Address">uw adres</data>
</culture>
</xmod:localization>
As you can see in the example above, you create one <xmod:localization> ... </xmod:localization> tag pair that wraps everything else. Within this tag, you define one or more <culture> tags for each locale you wish to support. Each locale is identified by a name (also called a key). United States English is "en-US", English in Great Britain would be "en-GB", French spoken in France is "fr-FR", etc. If you're in doubt as to which name to use, login to your DNN site as Host (or SuperUser) and navigate to the "Languages" tab (under the Host menu). There you'll see a list of languages available for your DNN site (and have the opportunity to install others). For those installed languages, look in the "key" column to get the name to use.
Within the <culture> tag, you define one or more <data> tags. Define one for each piece of text you wish to localize. In the example above we have defined translations for "Name" and "Address". Each <data> tag is identified by a "name" attribute. In this case, the "name" is a key that your [[localize]] tags will use to retrieve the appropriate text. Finally, the actual translated text is placed between the opening <data> and closing </data> tag. Here's an example of how you might use the above example data in your template:
<strong>[[localize:Name|Your Name]]</strong> <xmod:field name="txtName"/> <br />
<strong>[[localize:Address|Your Address]] <xmod:field name="txtAddress"/> <br />
Notice the [[localize]] tags . These are actually called "functions" or "function tags" in XMod. They are identified by using the [[ and ]] to encapsulate their contents. In the case of the [[localize]] function, the value following the colon (:) is the localization key. It's the "name" attribute from the <data> tag for which we want the translated value. That is then followed by a pipe character (|) and the text following that is what will be used as the default text, should no match be found. Notice that you don't have to specify a culture. XMod automatically grabs the current culture and ensures you get the text for that locale.
The <xmod:localization> tag has no attributes. Only one tag can be used per template. This tag can contain one or more <culture> tags. To incorporate translated text in your templates, you should also use the [[localize]]function.
The <culture> tag encapsulates one or more <data> tags which, in turn, encapsulate the translated text.
name |
The key which uniquely identifies the language/culture for which the included <data> tags are targeted. Some examples are:
|
The <data> tag has the attributes listed below. It also encloses the actual translated text.
name |
The key which identifies the this translated text within a <culture> tag. This key should be unique for all <data> tags within the <culture> tag. The can (and should) be duplicated in other <culture> tags. The name attribute is used by [[localize]] functions to locate the correct translated text. |
In the example below, the <xmod:localization> tag is in red while the [[localize]] function tags are in blue. Note that in addition to using [[localize]] functions to convert static text, you can also add more dynamism to your display by using it as the value of HTML properties . In this example, we switch the flag image based on the current language. Other possibilities might include switching CSS class names to give the page a different look depending on the language selected or switching whole CSS style sheets (in conjunction with the <xmod:scriptblock> tag to link stylesheets to your page).
<p>[[localize:CurrentLanguage|Currently Selected Langauge:]]
[[localize:LanguageName|English (US)]]
<img src="/images/[[localize:LanguageFlag|flag_us.gif]]"/>
</p>
<h3>[[localize:ContactInfoTitle|Contact Information]]</h3>
<p><strong>[[localize:Name|Name]]</strong> <xmod:field name="Name"/><br />
<strong>[[localize:Address|Address]]</strong> <xmod:field name="Address"/>
</p>
<xmod:localization>
<culture name="es-ES">
<data name="CurrentLanguage">Lengua Actual</data>
<data name="LanguageName">Español (España)</data>
<data name="LanguageFlag">flag_spain.gif</data>
<data name="Name">Su Nombre</data>
<data name="Address">Su Dirección</data>
</culture>
<culture name="fr-FR">
<data name="CurrentLanguage">Langue Courante</data>
<data name="LanguageName">Français (La France)</data>
<data name="LanguageFlag">flag_france.gif</data>
<data name="Name">Votre Nom</data>
<data name="Address">Votre Adresse</data>
</culture>
<culture name="nl-NL">
<data name="CurrentLanguage">huidige taal</data>
<data name="LanguageName">Nederlands (Nederland)</data>
<data name="LanguageImage">flag_netherlands.gif</data>
<data name="Name">uw naam</data>
<data name="Address">uw adres</data>
</culture>
</xmod:localization>