Template:LangToWiki: Difference between revisions

From Wikimedia Foundation Governance Wiki
Content deleted Content added
Vogone (talk | contribs)
m +sgs
Pols12 (talk | contribs)
Let’s use a pretty-complete module
Line 1: Line 1:
{{#invoke:langToWiki|wikidata|{{{1|{{int:lang}}}}}}}<noinclude>
{{#switch:{{int:lang}}|de-at=de|de-ch=de|de-formal=de|en-ca=en|en-gb=en|gsw=als|nl-informal=nl|pt-br=pt|sgs=bat-smg|{{int:lang}}}}<noinclude><br />

This template allows to use <nowiki>{{int:lang}}</nowiki> for linking to wikis depending on interface language settings here on metawiki. More rules may be added as required.</noinclude>
{{documentation|content=
This template returns the Wikidata interwiki identifier which matches with interface language or the given language code.

<templateData>
{
"params": {
"1": {
"label": "Language code",
"example": "pt-br",
"type": "string",
"suggested": true
}
},
"description": "Returns the Wikidata interwiki identifier string, from interface language or given language code.",
"format": "inline"
}
</templateData>

== Examples ==

* <code><nowiki>{{langToWiki}}</nowiki></code> gives <code>{{langToWiki}}</code>
* <code><nowiki>{{langToWiki|pt}}</nowiki></code> gives <code>{{langToWiki|pt}}</code>
* <code><nowiki>{{langToWiki|pt-br}}</nowiki></code> gives <code>{{langToWiki|pt-br}}</code>
* <code><nowiki>{{langToWiki|zh-hans}}</nowiki></code> gives <code>{{langToWiki|zh-hans}}</code>
* <code><nowiki>{{langToWiki|nan}}</nowiki></code> gives <code>{{langToWiki|nan}}</code>
* <code><nowiki>{{langToWiki|wikidata}}</nowiki></code> gives <code>{{langToWiki|wikidata}}</code> (not a language)
* <code><nowiki>{{langToWiki|abcdef}}</nowiki></code> gives <code>{{langToWiki|abcdef}}</code> (not a language)

}}

[[Category:Interwiki link templates]]
[[Category:Internationalization templates]]
</noinclude>

Revision as of 20:45, 16 October 2022

en

Template documentation

This template returns the Wikidata interwiki identifier which matches with interface language or the given language code.

Returns the Wikidata interwiki identifier string, from interface language or given language code.

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Language code1

no description

Example
pt-br
Stringsuggested

Examples

  • {{langToWiki}} gives en
  • {{langToWiki|pt}} gives pt
  • {{langToWiki|pt-br}} gives pt
  • {{langToWiki|zh-hans}} gives zh
  • {{langToWiki|nan}} gives zh_min_nan
  • {{langToWiki|wikidata}} gives wikidata (not a language)
  • {{langToWiki|abcdef}} gives abcdef (not a language)