Difference between revisions of "Help:Translation switching"

From Team Fortress Wiki
Jump to: navigation, search
(What should use translation switching?)
m (Related language templates)
 
(6 intermediate revisions by 4 users not shown)
Line 7: Line 7:
 
== What should use translation switching? ==
 
== What should use translation switching? ==
  
* In general, all templates should use it. This includes infoboxes to maintenance messages among others.
+
In general, all templates should use it.
* The exception to this currently are complicated [[:Category:Navigational templates|navigational templates]] using {{tl|Navbox}} (including "[[Template:Scout Nav|Scout Nav]]", "[[Template:Soldier Nav|Soldier Nav]]", etc). These should ''not'' use translation switching. They should be maintained on separate subpages instead.
 
* Simple nav templates such as [[Template:Class Nav|Class Nav]] and class hat table templates (e.g. [[Template:Scout class hat table|Scout class hat table]], etc), however, ''do'' use translation switching.
 
  
 
== How to add localized strings ==
 
== How to add localized strings ==
  
 
# Select a template from the [[:Category:Templates that use translation switching|list of templates]] that use translation switching.
 
# Select a template from the [[:Category:Templates that use translation switching|list of templates]] that use translation switching.
# Edit the template and add your strings (please use alphabetical ordering for convenience).  
+
# Edit the template and add your strings (please use alphabetical ordering for convenience, with the English string on top).  
 
# Update the template {{tl|translation switching}} or {{tl|ts}} towards the bottom of the page and add your language code to the list.
 
# Update the template {{tl|translation switching}} or {{tl|ts}} towards the bottom of the page and add your language code to the list.
  
Line 21: Line 19:
 
<pre><nowiki>
 
<pre><nowiki>
 
{{lang
 
{{lang
 +
  | en = Welcome
 +
  | cs = Vítejte
 
   | de = Willkommen
 
   | de = Willkommen
  | cs = Vítejte
 
  | en = Welcome
 
 
   | ja = Irashaimasu
 
   | ja = Irashaimasu
}}
+
  | ru = Добро пожаловать
 +
  }}
  
 
...
 
...
  
{{translation switching|de, cs, ja}}
+
{{translation switching|cs, de, ja, ru}}
 
</nowiki></pre>
 
</nowiki></pre>
  
Line 35: Line 34:
  
 
  <nowiki>{{lang</nowiki>
 
  <nowiki>{{lang</nowiki>
 +
  | en = Welcome
 +
  | cs = Vítejte
 
   | de = Willkommen
 
   | de = Willkommen
  | cs = Vítejte
 
  | en = Welcome
 
 
   <span style="font-weight:bolder;font-size:110%;color:#006F00;">| it = Benvenuto</span>
 
   <span style="font-weight:bolder;font-size:110%;color:#006F00;">| it = Benvenuto</span>
 
   | ja = Irashaimasu
 
   | ja = Irashaimasu
}}
+
  | ru = Добро пожаловать
 +
  }}
 
   
 
   
 
  ...
 
  ...
 
   
 
   
  <nowiki>{{</nowiki>translation switching|de, cs, <span style="font-weight:bolder;font-size:115%;color:#006F00;">it,</span> ja}}
+
  <nowiki>{{</nowiki>translation switching|cs, de, <span style="font-weight:bolder;font-size:115%;color:#006F00;">it,</span> ja, ru}}
  
 
Make sure to add the language to the {{tl|translation switching}} template towards the bottom of the page, also.
 
Make sure to add the language to the {{tl|translation switching}} template towards the bottom of the page, also.
 +
 +
:{{c|important}}: Remember to add language strings in alphabetical order, with English being on top.
  
 
== Templates without translation switching ==
 
== Templates without translation switching ==
Line 113: Line 115:
  
 
== Related language templates ==
 
== Related language templates ==
{{see also|:Category:Language templates}}
+
{{see also|Category:Language templates}}
 
For more advanced uses of translation switching we have the following templates:
 
For more advanced uses of translation switching we have the following templates:
  
Line 122: Line 124:
 
== See also ==
 
== See also ==
 
* [[Help:Language translation]] &ndash; how to translate normal article pages.
 
* [[Help:Language translation]] &ndash; how to translate normal article pages.
 +
 +
[[Category:Help]]
 +
[[Category:Team Fortress Wiki translation]]

Latest revision as of 17:34, 29 September 2022

Translation switching is used on many templates and other message boxes across the wiki. The template {{lang}} detects the name of the language page and switches the text. Its main purpose is to keep all localized versions of text centralized into one template.

In the past, translators would create pages like Template:Cleanup/ru, which would lead to a lot of misplaced and inconsistent localized templates. Now all translators have to do is simply add a few lines of code to the existing Template:Cleanup page and whenever that template is used on a Russian page, the template will automatically switch to show the Russian text.

What should use translation switching?

In general, all templates should use it.

How to add localized strings

  1. Select a template from the list of templates that use translation switching.
  2. Edit the template and add your strings (please use alphabetical ordering for convenience, with the English string on top).
  3. Update the template {{translation switching}} or {{ts}} towards the bottom of the page and add your language code to the list.

Example

Let's say you're adding Italian strings to a template. The template might already look like this:

{{lang
  | en = Welcome
  | cs = Vítejte
  | de = Willkommen
  | ja = Irashaimasu
  | ru = Добро пожаловать
  }}

...

{{translation switching|cs, de, ja, ru}}

So add your lines, copying the style of the ones above and below, so it looks like this:

{{lang
  | en = Welcome
  | cs = Vítejte
  | de = Willkommen
  | it = Benvenuto
  | ja = Irashaimasu
  | ru = Добро пожаловать
  }}

...

{{translation switching|cs, de, it, ja, ru}}

Make sure to add the language to the {{translation switching}} template towards the bottom of the page, also.

Pictogram comment.png Important: Remember to add language strings in alphabetical order, with English being on top.

Templates without translation switching

If you come across a particular template that requires translation switching and you want to add it, then feel free to make a start. The instructions below detail how to add {{lang}} to templates.

You may also wish to take a look at the list of other templates that have localized strings to try and copy the layout. Be aware of more intricate templates such as infobox templates as their uses of {{lang}} can be appear to be quite complex.

If you need help with a particular template, simply post on the talk page of it or contact one of the moderators or admins, as they'd be happy to help you.

Parts of templates

Let's say a template contains the text:

Lorem ipsum dolor '''[[Welcome]]''' lorem ipsum.

Now after modifying it for translation switching:

Lorem ipsum dolor '''[[{{lang
 | en = Welcome
 | ja = Irashaimasu
 }}]]''' lorem ipsum.

Notice there are no extra line breaks or spaces, like there are in this example:

Lorem ipsum dolor '''[[

{{lang
| en = Welcome
| ja = Irashaimasu
}}

]]''' lorem ipsum.

You can have as many line breaks as you want inside lang's {{ brackets }}, but outside there must be no spaces, line breaks or gaps at all.

Language links

Sometimes you may need to switch a link based on the language. A template may look like this:

[[Welcome|{{lang
| en = Welcome
| fr =  Accueil
}}]]

But you want the link to go to Welcome/fr instead of Welcome. This does the job:

[[Welcome{{if lang}}|{{lang
| en = Welcome
| fr = Accueil
}}]]

{{if lang}} tests whether the page is a language page, and if it is, it'll output the language code (in this case, it's /fr). So the link in this example will go to Welcome/fr, and the text displayed on the link will be French, as well.

It's important to not put a space in front of {{if lang}} (for example [[Hats {{if lang}}]]) This is because, when used in a link, it will produce Hats_/fr instead of Hats/fr.

Language categories

{{lang cat}} can be particularly handy for placing some templates in categories based on their language. For example, {{lang cat|Soldier}} will place German pages in Category:Soldier/de, and French pages in Category:Soldier/fr.

Related language templates

See also: Category:Language templates

For more advanced uses of translation switching we have the following templates:

  • {{lang cat}} – places a page in a particular category based on their language subpage name.
  • {{if lang}} – can produce two outputs based on whether the page is a language subpage or not (as opposed to {{lang}} which can define outputs on specific languages).
    • This is handy to avoid the use of {{lang}} like this: {{lang|de=_de|fr=_fr|ru=_ru}}

See also