Difference between revisions of "Template:Otherlang"

From Open Food Facts wiki
Jump to navigation Jump to search
(Template to add language versions of the page)
 
(Fixes alphabetical order of language links.)
 
(7 intermediate revisions by 3 users not shown)
Line 4: Line 4:
 
   | fr=Main_page:lang2
 
   | fr=Main_page:lang2
 
   }}
 
   }}
This template adds available translations for the page to the top.
+
This template adds links to available translations for the page to the top.
  
 
To prevent issues, this template must be placed '''at the very beginning of a page'''.
 
To prevent issues, this template must be placed '''at the very beginning of a page'''.
  
Tip! When contributing a new translation to a document that already has other translations, please carry over the existing translations to the otherlang template of your contributed page. This way all multilingual pages are linked.
+
Tip: When contributing a new translation to a document that already has other translations, please carry over the existing translations to the otherlang template of your contributed page. This way all multilingual pages are linked.
  
 
== Syntax ==
 
== Syntax ==
<pre>
 
  {{otherlang
 
  | de=Test:de
 
  | fr=Main_page:lang2
 
  | etc...
 
  }}
 
</pre>
 
  
Warning! Do not include the language of the current page. This will only confuse readers.
+
<nowiki>{{otherlang</nowiki>
 +
| ''LowercaseLanguageCode1''=''PageName1''
 +
| ''LowercaseLanguageCode2''=''PageName2''
 +
| ''[...]''
 +
}}
 +
 
 +
Note: Do not include a line for the language of the current page : this will add a link to the current page, which is useless and will only confuse readers.
  
 
=== Example ===
 
=== Example ===
On a page called [[Test]]:
 
  
<pre>
+
On an English wiki page named "Hello":
  {{otherlang
 
  | de=Test:de
 
  }}
 
</pre>
 
  
Note that:
+
<nowiki>{{otherlang</nowiki>
* The language "en" is not included, as it is the language of the page that template is being used on.
+
| de=DE:Hallo
* The English page has no suffix.
+
| fr=FR:Bonjour
* The same template must be used on the translated page (with the other language) to link back
+
| es=ES:Hola
 +
}}
 +
 
 +
Notice that there is no line for the English language, as it is the language of the page that template is being used on.
 +
 
 +
Note: The template will accept any page name. By convention however, translated pages are named according to the syntax <code>''UppercaseLanguageCode'':''TranslatedName''</code> ; as for English pages, they are named normally, without any <code>EN:</code> prefix.
  
 
== Available Languages ==
 
== Available Languages ==
 +
 
{| class="table table-bordered" border="2" cellpadding="7"
 
{| class="table table-bordered" border="2" cellpadding="7"
 
! Language
 
! Language
 
! Syntax
 
! Syntax
 +
|- id="de"
 +
|Deutsch
 +
|<code>de=DE:''TranslatedPageName''</code>
 
|- id="en"
 
|- id="en"
 
|English
 
|English
|en=Page_name
+
|<code>en=PageName</code>
|- id="de"
+
|- id="es"
|Deutsch
+
|Spanish
|de=Page_name:de
+
|<code>es=ES:''TranslatedPageName''</code>
 +
|- id="fr"
 +
|French
 +
|<code>fr=FR:''TranslatedPageName''</code>
 
|}
 
|}
  
Line 51: Line 57:
 
* https://developer.valvesoftware.com/wiki/Template:Otherlang2
 
* https://developer.valvesoftware.com/wiki/Template:Otherlang2
 
* https://developer.valvesoftware.com/wiki/Template:Lang
 
* https://developer.valvesoftware.com/wiki/Template:Lang
* https://wiki.micdoodle8.com/wiki/Template:Otherlang
+
* https://web.archive.org/web/20220125082843/https://wiki.micdoodle8.com/wiki/Template:Otherlang
 
* https://www.mediawiki.org/wiki/Template:Languages
 
* https://www.mediawiki.org/wiki/Template:Languages
 +
 +
See also other ways to do it:
 +
* https://wiki.openstreetmap.org/wiki/Template:Languages/div
 +
* https://wiki.openstreetmap.org/wiki/Template:Languages
  
 
</noinclude><div class="languages" style="clear:both;font-size:95%;line-height:normal;margin:2px 0;border:1px solid #AAA;background:#EEE;padding:1 rem;text-align: center;" dir="ltr">
 
</noinclude><div class="languages" style="clear:both;font-size:95%;line-height:normal;margin:2px 0;border:1px solid #AAA;background:#EEE;padding:1 rem;text-align: center;" dir="ltr">
'''Other languages'''<br>
+
'''Other languages:'''<br>
 
'''/''' {{
 
'''/''' {{
#if:{{{en|}}}|'''[[{{{en}}}|english]] /'''}} {{
+
#if:{{{de|}}}|'''[[{{{de}}}|Deutsch]] /'''}} {{
#if:{{{de|}}}|'''[[{{{de}}}|deutsch]] /'''}} {{
+
#if:{{{en|}}}|'''[[{{{en}}}|English]] /'''}} {{
 
#if:{{{es|}}}|'''[[{{{es}}}|español]] /'''}} {{
 
#if:{{{es|}}}|'''[[{{{es}}}|español]] /'''}} {{
 
#if:{{{fr|}}}|'''[[{{{fr}}}|français]] /'''}} {{
 
#if:{{{fr|}}}|'''[[{{{fr}}}|français]] /'''}} {{
#if:{{{it|}}}|'''[[{{{it}}}|italiano]] /'''}}
+
#if:{{{it|}}}|'''[[{{{it}}}|italiano]] /'''}} {{
 +
#if:{{{lt|}}}|'''[[{{{lt}}}|lietuvių]] /'''}}
 
</div>
 
</div>
 +
[[Category:Mediawiki Template]]

Latest revision as of 08:39, 7 September 2024

Other languages:
/ Deutsch / français /

This template adds links to available translations for the page to the top.

To prevent issues, this template must be placed at the very beginning of a page.

Tip: When contributing a new translation to a document that already has other translations, please carry over the existing translations to the otherlang template of your contributed page. This way all multilingual pages are linked.

Syntax

{{otherlang
| LowercaseLanguageCode1=PageName1
| LowercaseLanguageCode2=PageName2
| [...]
}}

Note: Do not include a line for the language of the current page : this will add a link to the current page, which is useless and will only confuse readers.

Example

On an English wiki page named "Hello":

{{otherlang
| de=DE:Hallo
| fr=FR:Bonjour
| es=ES:Hola
}}

Notice that there is no line for the English language, as it is the language of the page that template is being used on.

Note: The template will accept any page name. By convention however, translated pages are named according to the syntax UppercaseLanguageCode:TranslatedName ; as for English pages, they are named normally, without any EN: prefix.

Available Languages

Language Syntax
Deutsch de=DE:TranslatedPageName
English en=PageName
Spanish es=ES:TranslatedPageName
French fr=FR:TranslatedPageName

See also

Otherlang has been inspired by:

See also other ways to do it:

Other languages:
/