Sablon:Localization

Innen: Terraria Wiki
Ugrás a navigációhoz Ugrás a kereséshez

Localization mechanism for templates. Use {{L10n}} for short.

Usage

{{l10n|<namespace>|<key>|<lang>}}

Parameter 1

Namespace

Parameter 2

Key

Parameter 3 (optional)

Language, will be {{lang}} by default.

All named Parameters prefixed with $

Placeholders for format, will be replaced, see the example below.

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:

{{l10n/register|test|en
|abc=input: $x
|mn=abc$de$fg
|t = zzz
}}
A: {{l10n|test|abc|$x=xyz}}

B: {{l10n|test|mn|$d=kkkk|$f=jjjj}}

C: {{l10n|test|abc|$x={{l10n|test|mn|$d=x|$f=y}} }}

will result:

A: input: xyz

B: abckkkkejjjjg

C: input: abcxeyg

See {{l10n/register}} for about how to register localization info.

Example

Take {{hint}} for example:

Register localization info first:

<!-- 
//en version
-->{{l10n/register|hint|en<!--
	-->|hint=Hint:<!-- 
	-->|default=No hint provided.<!-- 
-->}}<!-- 
//it version
-->{{l10n/register|hint|it<!-- 
	-->|hint=Suggerimento:<!-- 
	-->|default=Nessun suggerimento fornito.<!-- 
-->}}<!-- 
... more other languages if needed.
-->

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

Example:

Code Result
Default:
{{hint}}
<!-- manual set language to IT -->
{{lang|it}}
Now will get Italian version:
{{hint}}
Default:
Guide.png
Hint: No hint provided.

Now will get Italian version:

Guide.png
Suggerimento: Nessun suggerimento fornito.

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