Template:Localization/doc

Localization mechanism for templates. Use L10n for short.

Usage
Namespace
 * Parameter 1

Key
 * Parameter 2

Language, will be  by default.
 * Parameter 3 (optional)

Placeholders for format, will be replaced, see the example below.
 * All named Parameters prefixed with

It will retrieve text of specified key for current language from localization database, If the text for current language does not exist, will use EN version instead.

You can define placeholder(s) for format purpose, even recursively, for example: A:

B:

C: will result:

Register Localization Info
L10n info is registered by using l10n/register. You can rely on autoload mechanism to load l10n database automatically, or register them manually before use.

Autoload
l10n will try to autoload l10n info by transclude  when needed. For example, for, l10n will try to transclude. In that database template, you should use l10n/register to register l10n info. This way is recommended because it reduces the number of l10n/register transcluding and improves performance.

Manually register
Just use l10n/register to register l10n info BEFORE l10n call.

Example
Take hint for example:

Register localization info first(in template:hint/l10n for autoload, or simply put on the top of template:hint):

then in template code, use l10n to retrieve text for current language from localization database, e.g., see source code of l10n for detail.

Example:

If you need to translate the template into another language, just add the registration code for the corresponding language.