i18n Module Examples
The i18n XQuery module is a general-purpose library to internationalize an XML document. For more information about the supported format read the documentation.
This page uses HTML templating. It calls the i18n module through a template instruction as follows:
<div data-template="i18n:translate" data-template-lang="es" data-template-catalogues="data/i18n">...</div>
The following files are used:
i18n.html | This document. |
i18n.xql | The i18n library module. |
collection_es.xml | The catalogue file for the Spanish translation. |
collection_de.xml | The catalogue file for the German translation. |
i18n:text
Markup
<i18n:text key="translateSimpleText">Translate simple text</i18n:text>
Result
Traducir simple texto
i18n:translate (numerical)
Markup
<i18n:translate> <i18n:text key="translateTextWithNumericalPropertiesSample">Text to translate with {2} parameters to substitute (in {1} order)</i18n:text> <i18n:param>numerical</i18n:param> <i18n:param>2</i18n:param> </i18n:translate>
Result
Traducir simple texto con 2 parámetros (a 'numerical' orden)
i18n:translate (alphabetical)
Markup
<i18n:translate> <i18n:text key="translateTextWithAlphabeticalPropertiesSample">Text to translate with {number} parameters to substitute (in {alphabetical} order)</i18n:text> <i18n:param key="alphabetical">alphabetical</i18n:param> <i18n:param key="number">2</i18n:param> </i18n:translate>
Result
Traducir simple texto con 2 parámetros (a 'alphabetical' orden)
i18n:translate (with translated parameter in numerical order)
Markup
<i18n:translate> <i18n:text key="translateTextWithTranslatedNumericalPropertiesSample">Text to translate with {1} to substitute</i18n:text> <i18n:param> <i18n:text key="translatedParameterValue">translated Parameter</i18n:text> </i18n:param> </i18n:translate>
Result
Traducir texto con parámetros por traducir
i18n:translate (with translated parameter in alphabetical order)
Markup
<i18n:translate> <i18n:text key="translateTextWithTranslatedAlphabeticalPropertiesSample">Text to translate with{translatedParameter} to substitute</i18n:text> <i18n:param key="translatedParameter"> <i18n:text key="translatedParameterValue">translated Parameter</i18n:text> </i18n:param> </i18n:translate>
Result
Traducir texto con parámetros por traducir
Attribute translation
Markup
<div id="testLocalizedAttributes" name="i18n(key1)" title="i18n(key2,defaultValue1)" class="i18n(nonExistingKey,value_for_not_existing_key)"/>
Result (take a look at the markup to verify the result)
translated attributes