Help:I18n & l10n for templates

On the Terraria Wikis, a template is -ready (i.e., prepared for internationalization – i18n – and localization – l10n) if its code can be shared between different languages without requiring to create a separate template for each language. This is achieved by splitting the functionality and the messages of the template – the functionality is always the same, but the messages are translated, if necessary, based on their translations stored within the code.

This system greatly simplifies the process of maintaining templates across numerous language variants' wikis. All i18n-ready templates can be found here: Category:I18n-ready templates.

Preparation
For any specific target language, some preparation is required to get it working properly with the i18n system of the Terraria Wikis.

For languages with a separate wiki
If the target language has its own wiki subdomain, the following steps are to be taken:


 * Port lang to the target language's wiki. Refer to the de and zh versions for examples.
 * Port l10n and l10n/register to the target language's wiki. This is as simple as copying the code of the English version.
 * Port tr to the target language's wiki. Refer to the de and zh versions for examples. If you still don't know how to set it up, simply put  as the content of the template. This makes it a dummy template, behaving similar to the English version.

For languages without a separate wiki
If the target language does not have its own wiki subdomain and instead exists within the English wiki on language subpages, the following step is to be taken:
 * Initialize the translation database of the target language: Create and/or fill, (e.g.   for Spanish). Refer to the es, it, and cs versions for examples. If you still don't know how to set it up, simply put   (e.g.   for Spanish) as the content of the template.

Localization
Once this preparation work has been successfully completed and the foundation for internationalization and localization of the target language has been laid, any i18n-ready template can now be localized to the target language. In order to do so, the following steps are to be taken, taking Chinese localization of achievement as an example:

Locate the localization section (usually at the very top of the code). At least the English messages are always already stored there. For achievement, we can see the en and fr l10n information:

Now, add the translated Chinese messages:

Please keep to the alphabetical order of the language codes, with English always at the very beginning.

Saving the changes now finalizes the Chinese localization of achievement. While for a language like Chinese, which has a separate wiki, a copy-paste to that language wiki is still required (see the result on the zh wiki), languages without a separate wiki are already done by now.

Lua-based templates
For Lua-based templates, such as item or eicons, the l10n work might need to be done within the Lua module. However, the process is largely the same – translate the existing English messages and add them to the l10n section of the modules. In modules, the l10n section usually consists of a text table and might also contain certain l10n-related functions or settings. See Module:Item and Module:Exclusive for examples.