Template:UselangLink: Difference between revisions
Template page
More actions
helpful link |
added option for naked link |
||
| Line 1: | Line 1: | ||
<onlyinclude>[{{fullurl:{{FULLPAGENAME}}|uselang={{{1}}}}} {{{text|{{#language:{{{1}}}}}}}}]</onlyinclude> | <onlyinclude>{{#if:{{{bare|}}}|{{fullurl:{{FULLPAGENAME}}|uselang={{{1}}}}}|[{{fullurl:{{FULLPAGENAME}}|uselang={{{1}}}}} {{{text|{{#language:{{{1}}}}}}}}]}}</onlyinclude> | ||
Takes a mandatory unnamed parameter containing a language code. Returns a link to the corresponding language version of the page it's used on. | Takes a mandatory unnamed parameter containing a language code. Returns a link to the corresponding language version of the page it's used on. | ||
The text of the link defaults to the language's [[w:autonym|autonym]], and can be replaced with the optional named parameter {{code|1={{!}}text=}} | The text of the link defaults to the language's [[w:autonym|autonym]], and can be replaced with the optional named parameter {{code|1={{!}}text=}} | ||
If the dummy parameter {{code|1={{!}}bare=}} is present, only the target link will be returned. | |||
Uses only [[mw:Help:Magic words|magic words]], should work on any MediaWiki installation. | Uses only [[mw:Help:Magic words|magic words]], should work on any MediaWiki installation. | ||
| Line 10: | Line 12: | ||
* {{tlc|UselangLink|ja}} yields {{UselangLink|ja}} | * {{tlc|UselangLink|ja}} yields {{UselangLink|ja}} | ||
* {{tlc|UselangLink|ja|2=text=Japanese}} yields {{UselangLink|ja|text=Japanese}} | * {{tlc|UselangLink|ja|2=text=Japanese}} yields {{UselangLink|ja|text=Japanese}} | ||
* {{tlc|UselangLink|ja|2=bare=yes}} yields {{UselangLink|ja|bare=yes}} | |||
* {{tlc|UselangLink|INVALID}} yields {{UselangLink|INVALID}} | * {{tlc|UselangLink|INVALID}} yields {{UselangLink|INVALID}} | ||
[[category:helper templates]] | [[category:helper templates]] | ||
[[category:internationalization templates]] | [[category:internationalization templates]] | ||
Revision as of 14:02, 13 January 2010
Takes a mandatory unnamed parameter containing a language code. Returns a link to the corresponding language version of the page it's used on.
The text of the link defaults to the language's autonym, and can be replaced with the optional named parameter |text=
If the dummy parameter |bare= is present, only the target link will be returned.
Uses only magic words, should work on any MediaWiki installation.
Examples
{{UselangLink|ja}}yields 日本語{{UselangLink|text=Japanese}}yields Japanese{{UselangLink|bare=yes}}yields https://wiki.neody.land/index.php?title=Template:UselangLink&uselang=ja{{UselangLink|INVALID}}yields invalid