Template:Sandbox/Aurelain/Translation: Difference between revisions

From Heroes of Might and Magic: Olden Era Official Wiki
No edit summary
No edit summary
 
(13 intermediate revisions by the same user not shown)
Line 8: Line 8:
     {{#if:{{{type|}}}|AND T.type="{{{type}}}"|}}
     {{#if:{{{type|}}}|AND T.type="{{{type}}}"|}}
| fields =
| fields =
     T.{{{field|name}}}
     CONCAT(T.{{{field|name}}})
| limit =
| limit =
     1
     1
Line 14: Line 14:
     {{{1}}}💬
     {{{1}}}💬
| more results text =
| more results text =
 
}}<!--
}}
--></includeonly><!--
{{#cargo_query:
tables  = Translation=T, Translation=EN
|join on = T.target_id = EN.target_id
|where  = T.target_id = '{{{1}}}' AND T.language='{{{2|en}}}'
          AND EN.target_id = '{{{1}}}' AND EN.language='en'
|fields  = IF('{{{3|}}}' = 'nolink' OR '{{{2|}}}' = 'nolink', T.name, CONCAT('[[', EN.name, '{{#ifeq:{{{2|en}}}|en||/{{{2}}}}}|', T.name, ']]'))
|limit  = 1
|more results text=
}}
<!--
################################################################################
################################################################################
--></includeonly><noinclude>
--><noinclude>


Retrieves the {{b|name}} value from the {{b|Translation}} Cargo table for a target id, in the desired language.
Retrieves the {{b|name}} value from the {{b|Translation}} Cargo table for a target id, in the desired language.
Line 34: Line 24:
from the {{b|Translation}} table, not just those prefixed with <code>wiki_</code>.
from the {{b|Translation}} table, not just those prefixed with <code>wiki_</code>.


== Usage ==


1. English:
==1. English:==
 
{{Color|yellow|Input:}} <code><nowiki>{{Sandbox/Aurelain/Translation|nature|en}}</nowiki></code>
 
{{Color|lime|Output:}} {{Sandbox/Aurelain/Translation|nature|en}}
 
 
==2. Japanese:==
 
{{Color|yellow|Input:}} <code><nowiki>{{Sandbox/Aurelain/Translation|nature|ja}}</nowiki></code>
 
{{Color|lime|Output:}} {{Sandbox/Aurelain/Translation|nature|ja}}
 
 
==3. Missing id:==
 
{{Color|yellow|Input:}} <code><nowiki>{{Sandbox/Aurelain/Translation|foo|en}}</nowiki></code>


{{Color|yellow|Input:}} <code><nowiki>{{Translation|wiki_units_no_counter|en}}</nowiki></code>
{{Color|lime|Output:}} {{Sandbox/Aurelain/Translation|foo|en}}


{{Color|lime|Output:}} {{Translation|wiki_units_no_counter|en}}


----
==4. Surrounded by text:==
2. Japanese:
(to prove this template doesn't add unexpected whitespace)


{{Color|yellow|Input:}} <code><nowiki>{{Translation|nature|ja}}</nowiki></code>
{{Color|yellow|Input:}} <code><nowiki>Hello{{Sandbox/Aurelain/Translation|nature|en}}World</nowiki></code>


{{Color|lime|Output:}} {{Translation|nature|ja}}
{{Color|lime|Output:}} Hello{{Sandbox/Aurelain/Translation|nature|en}}World


----
3. Missing id:


{{Color|yellow|Input:}} <code><nowiki>{{Translation|foo|en}}</nowiki></code>
==5. With {{b|type}}:==
(when collisions are a concern)


{{Color|lime|Output:}} {{Translation|foo|en}}
{{Color|yellow|Input:}} <code><nowiki>{{Sandbox/Aurelain/Translation|luck|en|type=unit_stat}}</nowiki></code>


----
{{Color|lime|Output:}} {{Sandbox/Aurelain/Translation|luck|en|type=unit_stat}}
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
==6. With {{b|field}}:==
(to get the description)


----
{{Color|yellow|Input:}} <code><nowiki>{{Sandbox/Aurelain/Translation|nature|en|field=description}}</nowiki></code>
5. With {{b|type}}, when collisions are a concern:


{{Color|yellow|Input:}} <code><nowiki>{{Translation|luck|en|type=unit_stat}}</nowiki></code>
{{Color|lime|Output:}} {{Sandbox/Aurelain/Translation|nature|en|field=description}}


{{Color|lime|Output:}} {{Translation|luck|en|type=unit_stat}}


----
==7. Getting a rich text:==
6. With {{b|field}}, to get the description:
(to prove html markup works)


{{Color|yellow|Input:}} <code><nowiki>{{Translation|nature|en|field=description}}</nowiki></code>
{{Color|yellow|Input:}} <code><nowiki>{{Sandbox/Aurelain/Translation|dragon|en|field=description}}</nowiki></code>


{{Color|lime|Output:}} {{Translation|nature|en|field=description}}
{{Color|lime|Output:}} {{Sandbox/Aurelain/Translation|dragon|en|field=description}}


__NOTOC__
</noinclude>
</noinclude>

Latest revision as of 11:47, 6 August 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_.


1. English:

Input: {{Sandbox/Aurelain/Translation|nature|en}}

Output: Grove


2. Japanese:

Input: {{Sandbox/Aurelain/Translation|nature|ja}}

Output: グローヴ


3. Missing id:

Input: {{Sandbox/Aurelain/Translation|foo|en}}

Output: foo💬


4. Surrounded by text:

(to prove this template doesn't add unexpected whitespace)

Input: Hello{{Sandbox/Aurelain/Translation|nature|en}}World

Output: HelloGroveWorld


5. With type:

(when collisions are a concern)

Input: {{Sandbox/Aurelain/Translation|luck|en|type=unit_stat}}

Output: Luck


6. With field:

(to get the description)

Input: {{Sandbox/Aurelain/Translation|nature|en|field=description}}

Output: Each of the Murmurwoods’ elemental spirits is a unique powerhouse, supported by equally strong — and expensive — rangers and druids.


7. Getting a rich text:

(to prove html markup works)

Input: {{Sandbox/Aurelain/Translation|dragon|en|field=description}}

Output: A powerful ancient creature, often intelligent and imbued with wondrous magic.

Morale range: 0 to 5.
Luck range: 0 to 3.

Fallen Dragons can be raised as Undead after battle.