Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Language/doc: Difference between revisions

Template page
link to documentation of {{#language}}
add templateBox and remove documentation of /XX subpages (currently not much used, and much less useful with the current version of language parser, can I delete them in a few weeks ?
Line 1: Line 1:
{{documentation subpage}}
{{TemplateBox
|name = language
|desc={{en|This template will return the name of a language given the language code. This template is made specifically for the language codes used in MediaWiki (often, but not always [[:en:ISO 639-3|ISO codes]] (see http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/cldr/ for details, and [[User:Rocket000/Languages/more]] for potentially missing languages)}}
}}


This template will return the name of a language given the language code. This template is made specifically for the language codes used in MediaWiki (not necessarily ISO codes, but see {{tl|Language/ISO 639/en}}).


This template is being migrated to core function <nowiki>{{#language}}</nowiki> documented at [[mw:Help:Magic_words#Miscellaneous]].  The [[:Category:Page using language code unsupported by language parser]] is populated by this template.
==examples==
 
==Examples==
The second parameter can be used to set the desired output language, otherwise it will return the name in the user's interface language (if a translation exists).
{|width="100%" border="0" cellspacing="0" cellpadding="0" class="wikitable" style="background:transparent"
|-
|width="50%" valign="top"|
* <nowiki>{{language|ar}}</nowiki> → {{language|ar}}
* <nowiki>{{language|ar|de}}</nowiki> → {{language|ar|de}}
* <nowiki>{{language|ar|en}}</nowiki> → {{language|ar|en}}
* <nowiki>{{language|ar|fr}}</nowiki> → {{language|ar|fr}}
* <nowiki>{{language|ar|he}}</nowiki> → {{language|ar|he}}
* <nowiki>{{language|ar|zh-hans}}</nowiki> → {{language|ar|zh-hans}}
|width="50%" valign="top"|
* <nowiki>{{language|en}}</nowiki> → {{language|en}}
* <nowiki>{{language|en|de}}</nowiki> → {{language|en|de}}
* <nowiki>{{language|en|en}}</nowiki> → {{language|en|en}}
* <nowiki>{{language|en|fr}}</nowiki> → {{language|en|fr}}
* <nowiki>{{language|en|he}}</nowiki> → {{language|en|he}}
* <nowiki>{{language|en|zh-hans}}</nowiki> → {{language|en|zh-hans}}
|-
|width="50%" valign="top"|
* <nowiki>{{language|is}}</nowiki> → {{language|is}}
* <nowiki>{{language|is|de}}</nowiki> → {{language|is|de}}
* <nowiki>{{language|is|en}}</nowiki> → {{language|is|en}}
* <nowiki>{{language|is|fr}}</nowiki> → {{language|is|fr}}
* <nowiki>{{language|is|he}}</nowiki> → {{language|is|he}}
* <nowiki>{{language|is|zh-hans}}</nowiki> → {{language|is|zh-hans}}
|width="50%" valign="top"|
* <nowiki>{{language|zh-hant}}</nowiki> → {{language|zh-hant}}
* <nowiki>{{language|zh-hant|de}}</nowiki> → {{language|zh-hant|de}}
* <nowiki>{{language|zh-hant|en}}</nowiki> → {{language|zh-hant|en}}
* <nowiki>{{language|zh-hant|fr}}</nowiki> → {{language|zh-hant|fr}}
* <nowiki>{{language|zh-hant|he}}</nowiki> → {{language|zh-hant|he}}
* <nowiki>{{language|zh-hant|zh-hans}}</nowiki> → {{language|zh-hant|zh-hans}}
|}
 
You can also use this template's subpages directly to achieve the same effect (which is also easier on the servers, but you need to know the UI language code to use as the fallback for the target translation, as the syntax above uses the second parameter to determine the fallback applicable to it, in order to generate the subpage names). Given that the current UI language code is <code><nowiki>{{int:Lang}}</nowiki>={{int:Lang}}</code>, the examples above are then equivalent to:


{|width="100%" border="0" cellspacing="0" cellpadding="0" class="wikitable" style="background:transparent"
{|width="100%" border="0" cellspacing="0" cellpadding="0" class="wikitable" style="background:transparent"
Line 50: Line 15:
* <nowiki>{{language/fr|ar}}</nowiki> → {{language/fr|ar}}
* <nowiki>{{language/fr|ar}}</nowiki> → {{language/fr|ar}}
* <nowiki>{{language/he|ar}}</nowiki> → {{language/he|ar}}
* <nowiki>{{language/he|ar}}</nowiki> → {{language/he|ar}}
* <nowiki>{{language/zh-hans|ar}}</nowiki> → {{language/zh-hans|ar}}
|width="50%" valign="top"|
|width="50%" valign="top"|
* <nowiki>{{language/{{Fallback|Language|{{int:Lang}}}}|en}}</nowiki> → {{language/{{Fallback|Language|{{int:Lang}}}}|en}}
* <nowiki>{{language/{{Fallback|Language|{{int:Lang}}}}|en}}</nowiki> → {{language/{{Fallback|Language|{{int:Lang}}}}|en}}
Line 57: Line 21:
* <nowiki>{{language/fr|en}}</nowiki> → {{language/fr|en}}
* <nowiki>{{language/fr|en}}</nowiki> → {{language/fr|en}}
* <nowiki>{{language/he|en}}</nowiki> → {{language/he|en}}
* <nowiki>{{language/he|en}}</nowiki> → {{language/he|en}}
* <nowiki>{{language/zh-hans|en}}</nowiki> → {{language/zh-hans|en}}
|-
|width="50%" valign="top"|
* <nowiki>{{language/{{Fallback|Language|{{int:Lang}}}}|is}}</nowiki> → {{language/{{Fallback|Language|{{int:Lang}}}}|is}}
* <nowiki>{{language/de|is}}</nowiki> → {{language/de|is}}
* <nowiki>{{language/en|is}}</nowiki> → {{language/en|is}}
* <nowiki>{{language/fr|is}}</nowiki> → {{language/fr|is}}
* <nowiki>{{language/he|is}}</nowiki> → {{language/he|is}}
* <nowiki>{{language/zh-hans|is}}</nowiki> → {{language/zh-hans|is}}
|width="50%" valign="top"|
* <nowiki>{{language/{{Fallback|Language|{{int:Lang}}}}|zh-hant}}</nowiki> → {{language/{{Fallback|Language|{{int:Lang}}}}|zh-hant}}
* <nowiki>{{language/de|zh-hant}}</nowiki> → {{language/de|zh-hant}}
* <nowiki>{{language/en|zh-hant}}</nowiki> → {{language/en|zh-hant}}
* <nowiki>{{language/fr|zh-hant}}</nowiki> → {{language/fr|zh-hant}}
* <nowiki>{{language/he|zh-hant}}</nowiki> → {{language/he|zh-hant}}
* <nowiki>{{language/zh-hans|zh-hant}}</nowiki> → {{language/zh-hans|zh-hant}}
|}
|}
Note that with this syntax, the use of the {{Tl|Fallback}} template is avoided in most cases because we know that templates do exist for all target languages specified in parameter 2 (de, en, fr, he, zh-hans), and that these templates contain a translation for all the languages specified in parameter 1 (ar, en, is, zh-hant). This is not necessarily true for all UI languages needed by users (notably for some rare UI languages, or newly added languages), for which a fallback translation to another language must be looked for.
==Subpages==
{{Special:PrefixIndex/Template:Language/}}
==See also==
* {{x|language}} - returns the local name of the language
* [[svn:/trunk/phase3/languages/Names.php]]
* {{tl|Language/ISO 639/en}} - returns the language name given a ISO 639 code (as opposed to the codes used in MediaWiki). Works for all 639-1, 639-2, 639-3 codes (you may have trouble editing it because of the size). Similar to [[:en:Template:Language]] and [[:fr:Modèle:Langue-local]].

Revision as of 14:45, 6 February 2012

English: This template will return the name of a language given the language code. This template is made specifically for the language codes used in MediaWiki (often, but not always ISO codes (see http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/cldr/ for details, and User:Rocket000/Languages/more for potentially missing languages)

Usage

{{language}}

The template takes no parameters.

Additional information

The template is intended to be used in the following namespaces: no namespace specified

The template is intended to be used by the following user groups: no user group specified


examples

Cookies help us deliver our services. By using our services, you agree to our use of cookies.