New to Version 5.0
This function is designed to work with the <localization> tag in XMod forms. By giving it the "name" of the localized item (also called the localization key) within that tag as well as a default value to use if no match is found, your forms can dynamically change their text and even their property values based on the current locale or language in your site.
This function can be used in XMod forms.
This function requires the <localization> tag be placed within the form in order to function.
Functions have certain common features. They are surrounded by { and ]] characters. Within these characters, you specify the name of the function first, followed immediately by a colon (:) if the function accepts additional input (called arguments). Each argument in the argument list is commonly separated by a pipe character (|).
The syntax for the [[localize]] function is very simple:
[[localize:localizationKey|defaultValue]]
localize |
The name of the function. Note the colon (:) is required and must immediately follow the name of the function. |
localizationKey |
Name which uniquely identifies an item within a given culture. This value corresponds to the name attribute of the <data> tag within the <localization> tag. Do not include any whitespace (spaces, tabs, etc.) as this will be included in the value that XMod tries to match. |
defaultValue |
This is the value XMod will output if the localizationKey for the current culture is not found. While this is not technically required, it is advisable to include this. This provides the mechanism by which the text for the default language of the site is rendered to the page. |
This function is executed before the form has been rendered to the page. This makes it possible to use it to dynamically set properties in addition to text.
Caution: There are certain portions of the form which shouldn't be localized - notably: all form tags and data values in list controls (i.e. the <value> tags within <select> and <select1> tags - though you can use it to set their <label> tags). Usage in this fashion may cause unpredictable results and is not supported.
This example uses the [[localize]] function in various places. Their usage is highlighted in red. Notice that, since this is a custom form, we not only localize the captions for the controls (the <span> tags), but also the <label> tags within the controls. This is because XMod uses the label value elsewhere in the application when a field's caption is being displayed to the end user. If you do not localize this, those instances will not be localized as well. Notice also that the form includes the required <localization> tag which includes the text translations.
FYI, if the translations are incorrect, blame BabelFish.com and then let us know so we can correct them :)
<form format="custom">
<controls>
<div>
<span>[[localize:Name|Your Name]]</span>
<input ref="Name">
<label>[[localize:Name|Your Name]]</label>
<default>[[localize:EnterName|Enter Your Name]]</default>
</input>
</div>
<div>
<span>[[localize:Address|Your Address]]</span>
<input ref="Address">
<label>[[localize:Address|Your Address]]</label>
<default>[[localize:EnterAddress|Enter Your Address]]</default>
</input>
</div>
<div>
<span>[[localize:SelectColor|Select a Color]]</span>
<select ref="selColor" appearance="minimal">
<label>[[localize:SelectColor|Select a Color]]</label>
<items>
<item>
<label>[[localize:Red|Red]]</label>
<value>#F00</value>
</item>
<item>
<label>[[localize:Green|Green]]</label>
<value>#0F0</value>
</item>
<item>
<label>[[localize:Blue|Blue]]</label>
<value>#00F</value>
</item>
</items>
</select>
</div>
<div>
<addbutton text="[[localize:Add|Add Item]]"/>
<cancelbutton text="[[localize:Cancel|Cancel Operation]]"/>
</div>
</controls>
<localization>
<culture name="es-ES">
<data name="Name">Nombre</data>
<data name="EnterName">Mecanografíe Su Nombre</data>
<data name="Address">Dirección</data>
<data name="EnterAddress">Mecanografíe Su Dirección</data>
<data name="SelectColor">Seleccione un color</data>
<data name="Red">Rojo</data>
<data name="Green">Verde</data>
<data name="Blue">Azul</data>
<data name="Add">Agregue El Artículo</data>
<data name="Cancel">Cancele La Operación</data>
</culture>
<culture name="fr-FR">
<data name="Name">Nom</data>
<data name="EnterName">Dactylographiez Votre Nom</data>
<data name="Address">Adresse</data>
<data name="EnterAddress">Dactylographiez Votre Adresse</data>
<data name="SelectColor">Choisissez La Couleur</data>
<data name="Red">Rouge</data>
<data name="Green">Vert</data>
<data name="Blue">Bleu</data>
<data name="Add">Ajoutez L'Article</data>
<data name="Cancel">Décommandez L'Opération</data>
</culture>
</localization>
</form>