Help:I18n & l10n for templates

On Terraria wiki(s), A template is "i18n-ready" (i18n means internationalization) means its code can be shared between different languages, so we don't need to create seperated version of this template for every language, just need to do some localization (l10n) work, translate some message text to target language. This makes it easier to port templates to another langugage, and makes it easier to maintain templates for different languages.

Preparation
For any specific target language, some preparation is required to get it working properly with the i18n mechanism of terraria wiki(s).

For languages with seperated wiki
If the target language has its own terraria wiki, e.g. German (de), Chinese (zh), Need to do the following:


 * Port lang template. You can refer to de version, zh version.
 * Port l10n, l10n/register templates, just copy the code of en version.
 * Port tr template. You can refer to de version, zh version. If you still don't know how to do it, just use  as its code, this will make it to be a dummy template.

For languages without seperated wiki
If the target language is within English terraria wiki as language subpages, e.g. Italian (it), Spanish (es), Need to do the following:
 * Initialize translation database of target language: create, (e.g.   for Spanish). You can refer to es version, it version, cz version. If you still don't know how to do it, just use   (e.g.  ) as its code.

Localization
Now all i18n-ready templates will works for your language. But you still need to do l10n work to make them display text in target language (on pages of that language).

Take hint for example, Suppose we want to localize it for Chinese (zh):

You can see there already en and it l10n info registered:

Now added Chinese version:

That's all. You don't need to edit functional code of template, just register l10n info for your language. Of course, since zh is on a separate wiki, you still need to do a copy-paste to updated this template on zh wiki. For those languages within main en wiki, just save the edit.

You can see the result on zh wiki.

Lua-based templates
For Lua-based templates, such as item, eicons, l10n work may need to be done within lua module. All l10n-related part will be on the top of code, you just need to edit this part for l10n. This part usually contains an l10n text table and may also contain l10n functions or settings. See Module:Item and Module:Exclusive for example.