Template:Localized link: Difference between revisions
(initial copy; code cleaning) |
(+Todo: improve to handle Category_title) |
||
Line 13: | Line 13: | ||
|</b> | |</b> | ||
}}<span style="display:none">{{#ifexist:{{{1}}}|[[:{{{1}}}]]}}</span><noinclude> | }}<span style="display:none">{{#ifexist:{{{1}}}|[[:{{{1}}}]]}}</span><noinclude> | ||
{{Todo|Improve template to handle case with translatable pages from Category namespace which uses Category_title instead of Page_display_title}} | |||
{{Documentation}} | {{Documentation}} | ||
</noinclude> | </noinclude> |
Latest revision as of 11:35, 20 June 2018
[[Special:MyLanguage/{{{1}}}|{{{1}}}]]
Purpose
This helper template can be used to link to translatable pages in the user's language. It uses the special page prefix Special:MyLanguage/
, which checks if there is a translated version of a page in the user's language, and links to it if there is one, and links to a fallback language where available, or the default wiki language version (English in MediaWiki) if there isn't.
It should be used in translated pages, so that they link to the right page even if there is no translated page in that language.
Usage
TemplateData for Localized link
Link to translatable page in the user's language. It uses the special page prefix "Special:MyLanguage/".
Parameter | Description | Type | Status | |
---|---|---|---|---|
Page name | 1 | no description | Page name | required |
2 | 2 Custom label | no description
| String | optional |
If 'nsp
' parameter is not defined, as link text displays the full pagename (including namespace); otherwise — if 'nsp
' parameter is defined by any value — link text displays the short pagename, without namespace.
Examples of simple usage
Use | Becomes |
---|---|
{{ll|Communication}}
|
Communication |
{{ll|Communication|コミュニケーション}}
|
コミュニケーション |
{{ll|Project:About}}
|
Project:About |
{{ll|Project:About|nsp=0}}
|
About |
Usage in translatable pages
On pages prepared for translation with the Translate extension, this template may be used in three ways.
- Inside translation unit (inline with text), in case of custom label, better would be to use standard wikilink syntax and then embed link target into a
<tvar|id>...</>
.- As example, instead of
{{ll|Communication|About communication}}
, better would be[[<tvar|comm>Special:MyLanguage/Communication</>|About communication]]
.
- As example, instead of
- Outside of translation unit or in some other cases, when you have custom label, better would be to mark for translation only label.
- As example, for
some text {{ll|Communication|About communication}} some text
, translation markup in translatable page will be: <translation>some text</translation> {{ll|Communication|<translation>About communication</translation>}} <translation>some text</translation>
.- This is useful for bulleted lists of links, e.g., in the "See also:" sections.
- As example, for
- If link text does not have to be different from the name of landing page, then better would be to embed the whole template call code into
<tvar>
.- As example, instead of
{{ll|Communication}}
better would be<tvar|about-meta>{{ll|Communication}}</>
.
- As example, instead of
Source
Code taken from Mediawiki - Template:Localized_link
See also
- Template:Localized link/messagedoc – should be used for message documentation in translatable pages that use this template.
- {{Translatable template}}
- {{Translatable template name}}, alias {{Template:Translatable template name}} or {{tntn}}
The above documentation is transcluded from Template:Localized link/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |