Template:Language

Revision as of 23:48, 2 February 2009 by Maintenance script (talk) (Importing image file)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
[edit] Template-info.svg Template documentation

This template is used to convert ISO 639 language codes into language names

Usage

  • Parameter 1 (compulsory) is the ISO 639-1 (two-letter) or ISO 639-2 (three letter) code for the language to output.
  • Parameter 2 (optional) is the two- or three-letter code for the language the result should be displayed in. If no valid parameter is given, the default is en

Please note that this system requires a huge number of separate language names (~35,000) and so is currently very incomplete. If the required name has not already been defined for a particular language, the template will display an error (if no translations have been specified for the language, english translations will be returned). If you feel confident enough with a language that is not already defined, please take a few moments to create a new set of definitions for it.

Examples

  • {{language|en}} → Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".

  • {{language|fr}} → Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".

  • {{language|en|fr}} → frLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".Expression error: Unrecognized word "en".

  • {{language|fr|en}} → enLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".

  • {{language|fr|fr}} → frLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".Expression error: Unrecognized word "fr".

Technical details

This template works by calling a subpage with the relevant language code for the second parameter (the return language); this subpage contains a switch statement that converts the first parameter into the name in the appropriate language. See for instance {{language/en}}, which is called to translate codes into English. To translate language codes into French, say, you would create {{language/fr}} with a similar format, replacing the English terms for each language with the corresponding French terms. To allow the subpage to be used, you would edit the template and insert a line <nowiki|fr=fr</nowiki>:

{{#iferror:<!--
 
 -->{{Language/<!--
   -->{{#switch:{{lc:{{{2|en}}}}}
       ||en|#default = en
       |fr = fr
      }}<!--
 --> | {{{1|}}} }}<!--

  -->|{{Language/<!--
     -->{{#switch:{{lc:{{{2|en}}}}}
         ||en|#default = en+
       |fr = fr+
        }}<!--
  --> | {{{1|}}} }}<!--

 -->}}<!--
 
 --><noinclude>

Because some language codes are very uncommon, it is possible to split a language into two subpagges, eg /fr and /fr+. The /fr page is called first, and should contain the more common languages. Less common languages should be added to the /fr+ page, which is called only if no translation is found in the main subpage; between them, the two pages should contain all the available translations. To add a /fr+ subpage, add a line to the second switch block in the main template, as shown above.

See also