Template:Lang: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
Sur (talk | contribs)
testing purposes for now
 
Saag (talk | contribs)
Changed template to make use of the Lang module
Line 1: Line 1:
{{#switch:{{{force|{{SUBPAGENAME}}}}}
{{#if:{{{key}}}|{{#invoke:Lang|get_string|{{{key}}}|{{{lang_code|{{SUBPAGENAME}}}}}}}|
| ar = {{{ar|{{{en|{{{1}}}}}}}}}
{{#if:{{{label}}}|{{#invoke:Lang|search_string|{{{label}}}|{{{lang_code|{{SUBPAGENAME}}}}}}}|
| bg = {{{bg|{{{en|{{{1}}}}}}}}}
"label" or "key" is required}}}}
| cs = {{{cs|{{{en|{{{1}}}}}}}}}
 
| da = {{{da|{{{en|{{{1}}}}}}}}}
<noinclude>
| de = {{{de|{{{en|{{{1}}}}}}}}}
=== Examples ===
| es = {{{es|{{{en|{{{1}}}}}}}}}
Retrieve French word by the attribute key
| fi = {{{fi|{{{en|{{{1}}}}}}}}}
<pre>{{Lang|key=BonusClipSize_label|lang_code=fr}} -> "Munitions"</pre>
| fr = {{{fr|{{{en|{{{1}}}}}}}}}
 
| hu = {{{hu|{{{en|{{{1}}}}}}}}}
Retrieve French string by label
| it = {{{it|{{{en|{{{1}}}}}}}}}
<pre>{{Lang|label=Ammo|lang_code=fr}} -> "Munitions"</pre>
| ja = {{{ja|{{{en|{{{1}}}}}}}}}
 
| ko = {{{ko|{{{en|{{{1}}}}}}}}}
 
| nl = {{{nl|{{{en|{{{1}}}}}}}}}
<templatedata>
| no = {{{no|{{{en|{{{1}}}}}}}}}
{
| pl = {{{pl|{{{en|{{{1}}}}}}}}}
"params": {
| pt = {{{pt|{{{en|{{{1}}}}}}}}}
"key": {
| pt-br = {{{pt-br|{{{en|{{{1}}}}}}}}}
"description": "Attribute key to directly retrieve the localized string from its JSON file",
| ro = {{{ro|{{{en|{{{1}}}}}}}}}
"example": "BonusClipSize_label",
| ru = {{{ru|{{{en|{{{1}}}}}}}}}
"type": "string"
| sv = {{{sv|{{{en|{{{1}}}}}}}}}
},
| th = {{{th|{{{en|{{{1}}}}}}}}}
"lang_code": {
| tr = {{{tr|{{{en|{{{1}}}}}}}}}
"description": "Two-letter language code for selecting language of string",
| uk = {{{uk|{{{en|{{{1}}}}}}}}}
"example": "en",
| vi = {{{vi|{{{en|{{{1}}}}}}}}}
"type": "string",
| zh-hans = {{{zh-hans|{{{en|{{{1}}}}}}}}}
"default": "Defaults to \"en\" (English), or if the URL has the code at the end, it will use that"
| zh-hant = {{{zh-hant|{{{en|{{{1}}}}}}}}}
},
| #default = {{{en|{{{1|}}}}}}
"label": {
}}
"description": "Used to search for the string by its English label instead of using the attribute key directly",
"example": "Ammo",
"type": "string"
}
},
"description": "Template for retrieving localized strings from their relevant json file, such as `Data:Lang_en.json` for english. Supports search via the key or by referencing it using the English string"
}
</templatedata>
</noinclude>

Revision as of 13:02, 15 September 2024


Examples

Retrieve French word by the attribute key

{{Lang|key=BonusClipSize_label|lang_code=fr}} -> "Munitions"

Retrieve French string by label

{{Lang|label=Ammo|lang_code=fr}} -> "Munitions"


Template for retrieving localized strings from their relevant json file, such as `Data:Lang_en.json` for english. Supports search via the key or by referencing it using the English string

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
keykey

Attribute key to directly retrieve the localized string from its JSON file

Example
BonusClipSize_label
Stringoptional
lang_codelang_code

Two-letter language code for selecting language of string

Default
Defaults to "en" (English), or if the URL has the code at the end, it will use that
Example
en
Stringoptional
labellabel

Used to search for the string by its English label instead of using the attribute key directly

Example
Ammo
Stringoptional