Template:Lang/doc: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
Sur (talk | contribs)
m minor phrasing for label's description
Sur (talk | contribs)
m examples now dynamic
Line 6: Line 6:
=== Examples ===
=== Examples ===
==== Retrieve word by the attribute key ====
==== Retrieve word by the attribute key ====
<pre>English string: {{Lang|key=BonusClipSize_label}} -> "Ammo"</pre>
<pre style="width:fit-content;>English string: {{Lang|key=BonusClipSize_label}} -></pre> {{Lang|key=BonusClipSize_label}}<br><br>
<pre>French string:  {{Lang|key=BonusClipSize_label|lang_code=fr}} -> "Munitions"</pre>
<pre style="width:fit-content;>French string:  {{Lang|key=BonusClipSize_label|lang_code=fr}} -></pre> {{Lang|key=BonusClipSize_label|lang_code=fr}}<br><br>


==== Retrieve string by label ====
==== Retrieve string by label ====
<pre>English string: {{Lang|label=Ammo}} -> "Ammo"</pre>
<pre style="width:fit-content;>English string: {{Lang|label=Ammo}} -></pre> {{Lang|label=Ammo}}<br><br>
<pre>French string:  {{Lang|label=Ammo|lang_code=fr}} -> "Munitions"</pre>
<pre style="width:fit-content;>French string:  {{Lang|label=Ammo|lang_code=fr}} -></pre> {{Lang|label=Ammo|lang_code=fr}}<br><br>


<templatedata>
<templatedata>

Revision as of 19:09, 15 September 2024

Overview

Template for retrieving localized strings from their relevant json file, such as Data:Lang_en.json for English. Note that localized strings are all pulled from raw game files.

Supports retrieval via the JSON key or by referencing it using the English label

Examples

Retrieve word by the attribute key

English string: {{Lang|key=BonusClipSize_label}} ->

Ammo

French string:  {{Lang|key=BonusClipSize_label|lang_code=fr}} ->

Lang code 'fr' does not have a json file

Retrieve string by label

English string: {{Lang|label=Ammo}} ->

Ammo

French string:  {{Lang|label=Ammo|lang_code=fr}} ->

Lang code 'fr' does not have a json file

No description.

Template parameters

ParameterDescriptionTypeStatus
keykey

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

Example
BonusClipSize_label
Stringoptional
labellabel

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

Example
Ammo
Stringoptional
lang_codelang_code

Two-letter language code for selecting language of string. Note that this should not usually be used, as the lang code will be pulled from the URL subpage.

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