Difference between revisions of "Template:Lang"

From Kerbal Space Program Wiki
Jump to: navigation, search
m (*maybe also be able in category ns;)
m (*renamed Parameter Table to Parameter table;)
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{#switch:{{#if: {{{force|}}}|{{{force}}}|{{#ifeq: {{#titleparts:{{PAGENAME}}||-1}}|{{BASEPAGENAME}}|en|{{#titleparts:{{PAGENAME}}||-1}}}}}}
+
{{Lang/choices|{{#switch:{{#if: {{{force|}}}|{{{force}}}|{{#ifeq: {{#titleparts:{{PAGENAME}}||-1}}|{{BASEPAGENAME}}|en|{{#titleparts:{{PAGENAME}}||-1}}}}}}
| ar = {{{ar|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| ar = {{{ar|}}}
| cs = {{{cs|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| cs = {{{cs|}}}
| da = {{{da|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| da = {{{da|}}}
| de = {{{de|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| de = {{{de|}}}
| en = {{{en|{{{1}}}}}}
+
| en = {{{en|}}}
| es = {{{es|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| es = {{{es|}}}
| fi = {{{fi|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| fi = {{{fi|}}}
| fr = {{{fr|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| fr = {{{fr|}}}
| hu = {{{hu|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| he = {{{he|}}}
| it = {{{it|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| hr = {{{hr|}}}
| ja = {{{ja|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| hu = {{{hu|}}}
| ko = {{{ko|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| it = {{{it|}}}
| nl = {{{nl|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| ja = {{{ja|}}}
| no = {{{no|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| ko = {{{ko|}}}
| pl = {{{pl|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| nl = {{{nl|}}}
| pt = {{{pt|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| no = {{{no|}}}
| pt-br = {{{pt-br|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| pl = {{{pl|}}}
| ro = {{{ro|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| pt = {{{pt|}}}
| ru = {{{ru|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| pt-br = {{{pt-br|}}}
| sv = {{{sv|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| ro = {{{ro|}}}
| tr = {{{tr|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| ru = {{{ru|}}}
| zh = {{{zh|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| sv = {{{sv|}}}
| zh-cn = {{{zh-cn|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| th = {{{th|}}}
| zh-tw = {{{zh-tw|{{{default|{{{en|{{{1}}}}}}}}}}}}
+
| tr = {{{tr|}}}
| #default = {{{default|{{{en|{{{1}}}}}}}}}
+
| zh = {{{zh|}}}
}}<noinclude>{{doc start}}
+
| zh-cn = {{{zh-cn|}}}
 +
| zh-tw = {{{zh-tw|}}}
 +
| #default = {{{default|}}}
 +
}}|{{{default|}}}|{{{en|}}}|{{{1|}}}}}<noinclude>{{doc start}}
 
The main purpose of this template is to retain consistency across multiple translated pages. {{tlx|lang}} will detect the language page name, and display that language's translation by itself (e.g. if a template with Polish translations in it, when used on a Polish page, only the Polish translations will be displayed).
 
The main purpose of this template is to retain consistency across multiple translated pages. {{tlx|lang}} will detect the language page name, and display that language's translation by itself (e.g. if a template with Polish translations in it, when used on a Polish page, only the Polish translations will be displayed).
  
 
By default, {{tlx|lang}} will display English if no translation is available for a particular language.
 
By default, {{tlx|lang}} will display English if no translation is available for a particular language.
  
== Usage ==
+
== Parameters ==
* To define a language, simply use the code <code>| xx = </code> and then add your translation after (replacing xx with the correct code from below).
+
{{Parameter table|name=text|parameters=
 +
{{Parameter row|en|name2=1|English original text/translation. If not given uses {{{default}}}.|<tt>{{{default}}}</tt>}}
 +
{{!}}-
 +
{{!}} ''language code''
 +
{{!}} {{Yes}}
 +
{{!}} The translations into the languages defined by the language codes. The the table below for the available language codes.
 +
{{Parameter row|force|Forces a particular language regardless of the {{code|SUBPAGENAME}}. Usually used to test if the language does work.|Not set/automatic}}
 +
{{Parameter row|default|Default text if there is no translation given for the language. If not given uses the English text/translation.|<tt>{{{en}}}</tt> or <tt>{{{1}}}</tt>}}
 +
}}
  
 
{| class="wikitable grid" style="margin: 1em 0;"
 
{| class="wikitable grid" style="margin: 1em 0;"
 
! Available languages
 
! Available languages
| ar, cs, da, de, es, fi, fr, hu, it, ja, ko, nl, no, pl, pt, pt-br, ro, ru, sv, tr, zh, zh-cn, zh-tw
+
| ar, cs, da, de, es, fi, fr, he, hr, hu, it, ja, ko, nl, no, pl, pt, pt-br, ro, ru, sv, th, tr, zh, zh-cn, zh-tw
 
|}
 
|}
 
=== Options ===
 
* '''Forcing a particular language''': the parameter {{code|force}} is available to force a particular language to show regardless of the {{code|SUBPAGENAME}}. It can be useful on some templates to force English to always show.
 
::Example: {{tlx|lang|2=force=en}}
 
* '''Default language''': the parameter {{code|default}} can be defined and will be selected instead of the English if set.
 
  
 
=== Examples ===
 
=== Examples ===
Line 53: Line 59:
 
</pre>
 
</pre>
  
[[Category:Templates|Lang]]
+
[[Category:Language templates]]
[[Category:Language templates|Lang]]
+
[[Category:Language code templates]]
[[Category:Templates from the Team Fortress 2 Wiki|Lang]]
+
[[Category:Templates from the Team Fortress 2 Wiki]]
 
</noinclude>
 
</noinclude>

Revision as of 12:09, 19 December 2014

Documentation for Lang

The main purpose of this template is to retain consistency across multiple translated pages. {{lang}} will detect the language page name, and display that language's translation by itself (e.g. if a template with Polish translations in it, when used on a Polish page, only the Polish translations will be displayed).

By default, {{lang}} will display English if no translation is available for a particular language.

Parameters

Name Optional Description Default
en or 1 Yes English original text/translation. If not given uses {{{default}}}. {{{default}}}
language code Yes The translations into the languages defined by the language codes. The the table below for the available language codes.
force Yes Forces a particular language regardless of the SUBPAGENAME. Usually used to test if the language does work. Not set/automatic
default Yes Default text if there is no translation given for the language. If not given uses the English text/translation. {{{en}}} or {{{1}}}
Available languages ar, cs, da, de, es, fi, fr, he, hr, hu, it, ja, ko, nl, no, pl, pt, pt-br, ro, ru, sv, th, tr, zh, zh-cn, zh-tw

Examples

{{lang
| de = Willkommen
| en = Welcome
| ja = Irashaimasu
| pl = Witaj
}}