Skip to content

Internationalization

Gabriel Zerbib edited this page Feb 28, 2017 · 1 revision

FigDice provides a mechanism for key-based translation of all the text contained in your templates.

All you have to do, is indicate where in your templates the international messages are located, by enclosing them in fig:trans tags.

Language files are organized in XML dictionaries of key-value entries.

A fig:trans tag indicates a dictionary name, the key of the message to translate, and optional named parameters in the shape of inline attributes or fig:param children tags (same syntax as in fig:call).

Example of template with i18n:

	<!-- Import two dictionaries into my current template: -->
	<fig:dictionary name="Product" file="product.xml" />
	<fig:dictionary name="Errors" file="common/errors.xml" />

	<!-- Display a translated message: -->
	<fig:trans dict="Product" key="PRODUCT_DESCRIPTION_COLUMN" />

	<!-- Display a translated message with a parameter: -->
	<fig:trans dict="Errors" key="MINIMUM_CHARS_EXPECTED" minChars=" 20 " />

In the dictionaries file, the parameters of an entry are usable by their name, enclosed in curly braces:

	<entry key="MINIMUM_CHARACTERS_EXPECTED">
		Please enter at least {minChars} characters.
	</entry>
Clone this wiki locally