Template:Translation: Difference between revisions

From Heroes of Might and Magic: Olden Era Official Wiki
No edit summary
No edit summary
Line 6: Line 6:
     T.target_id = "{{{1}}}"
     T.target_id = "{{{1}}}"
     AND T.language = "{{{2|en}}}"
     AND T.language = "{{{2|en}}}"
| fields = T.name|limit = 1|default = —| more results text =}}<!--
| fields =
    T.name
| limit =
    1
| default =
    —
| more results text =
 
}}<!--
################################################################################
################################################################################
--></includeonly><noinclude>
--></includeonly><noinclude>
Line 17: Line 25:
== Usage ==
== Usage ==


1. English
1. English:


{{Color|yellow|Input:}} <code><nowiki>{{Translation|nature|en}}</nowiki></code>
{{Color|yellow|Input:}} <code><nowiki>{{Translation|nature|en}}</nowiki></code>
Line 24: Line 32:


----
----
2. Japanese
2. Japanese:


{{Color|yellow|Input:}} <code><nowiki>{{Translation|nature|ja}}</nowiki></code>
{{Color|yellow|Input:}} <code><nowiki>{{Translation|nature|ja}}</nowiki></code>
Line 31: Line 39:


----
----
3. Missing id
3. Missing id:


{{Color|yellow|Input:}} <code><nowiki>{{Translation|foo|en}}</nowiki></code>
{{Color|yellow|Input:}} <code><nowiki>{{Translation|foo|en}}</nowiki></code>


{{Color|lime|Output:}} {{Translation|foo|en}}
{{Color|lime|Output:}} {{Translation|foo|en}}
----
4. Surrounded by text, to prove this template doesn't add unexpected whitespace:
{{Color|yellow|Input:}} <code><nowiki>Hello{{Translation|nature|en}}World</nowiki></code>
{{Color|lime|Output:}} Hello{{Translation|nature|en}}World


</noinclude>
</noinclude>

Revision as of 15:02, 14 July 2026


Retrieves the name value from the Translation Cargo table for a target id, in the desired language.

This is very similar to the Label template, but is more generic, allowing you to pull any id from the Translation table, not just those prefixed with wiki_.

Usage

1. English:

Input: {{Translation|nature|en}}

Output: Grove


2. Japanese:

Input: {{Translation|nature|ja}}

Output: グローヴ


3. Missing id:

Input: {{Translation|foo|en}}

Output: —


4. Surrounded by text, to prove this template doesn't add unexpected whitespace:

Input: Hello{{Translation|nature|en}}World

Output: HelloGroveWorld