Difference between revisions of "Help:Translation switching"

From Team Fortress Wiki
Jump to: navigation, search
m ("Willkommen" with double L)
m
Line 3: Line 3:
 
'''Translation switching''' is used on many templates and other message boxes across the wiki. The template '''{{tl|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.  
 
'''Translation switching''' is used on many templates and other message boxes across the wiki. The template '''{{tl|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. Whereas 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.
+
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? ==
 
== What should use translation switching? ==
Line 17: Line 17:
  
 
=== Example ===
 
=== Example ===
Let's say you're adding Italian strings to a template. It might look like this
+
Let's say you're adding Italian strings to a template. The template might already look like this:
 
<pre><nowiki>
 
<pre><nowiki>
 
{{lang
 
{{lang
Line 31: Line 31:
 
</nowiki></pre>
 
</nowiki></pre>
  
So you add your lines copying the style of the ones above and below so it looks like this:
+
So add your lines, copying the style of the ones above and below, so it looks like this:
  
 
  <nowiki>{{lang</nowiki>
 
  <nowiki>{{lang</nowiki>
Line 37: Line 37:
 
   | cs = Vítejte
 
   | cs = Vítejte
 
   | en = Welcome
 
   | en = Welcome
   <span style="font-weight:bolder;color:#006F00;">| it = Benvenuto</span>
+
   <span style="font-weight:bolder;font-size:110%;color:#006F00;">| it = Benvenuto</span>
 
   | ja = Irashaimasu
 
   | ja = Irashaimasu
 
  }}
 
  }}
Line 43: Line 43:
 
  ...
 
  ...
 
   
 
   
  <nowiki>{{</nowiki>translation switching|de, cs, <span style="font-weight:bolder;color:#006F00;">it,</span> ja}}
+
  <nowiki>{{</nowiki>translation switching|de, cs, <span style="font-weight:bolder;font-size:115%;color:#006F00;">it,</span> ja}}
  
 
== Templates without translation switching ==
 
== Templates without translation switching ==

Revision as of 00:27, 15 August 2010

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. This includes infoboxes to maintenance messages, etc.
  • The exception to this currently is navigational templates which use {{Navbox}}. These should be maintained on separate template pages.

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).
  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
  | de = Willkommen
  | cs = Vítejte
  | en = Welcome
  | ja = Irashaimasu
}}

...

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

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

{{lang
  | de = Willkommen
  | cs = Vítejte
  | en = Welcome
  | it = Benvenuto
  | ja = Irashaimasu
}}

...

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

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 start us off. Take a look at the list of other templates that have localized strings and 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 and they'd be happy to help you.

Related language templates

See also: [[::Category:Language templates|: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