Template:Localized link/doc: Difference between revisions

From Miranda NG
Jump to navigation Jump to search
(initial copy)
 
(correct and rephrase usage cases)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
{{Shortcut|Template:Ll}}


== Purpose ==
== Purpose ==
Line 7: Line 8:


== Usage ==
== Usage ==
 
{{TemplateDataHeader}}
<templatedata>
<templatedata>
{
{
Line 53: Line 54:
== Usage in translatable pages ==
== Usage in translatable pages ==


On pages prepared for translation with the [[Extension:Translate|Translate extension]], this template may used in three ways.  
On pages prepared for translation with the [[mediawikiwiki:Extension:Translate|Translate extension]], this template may be used in three ways.  
# Should better be substitute this template, and then the wikilink target embedded in a <code><tvar|id>...</></code>, separately from the translatable displayed text of the link.  
# 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 <code><tvar|id>...</></code>.
#: As example, instead <code><nowiki>{{ll|Communication|About communication}}</nowiki></code>, translation markup in translatable page will be <code><nowiki>[[<tvar|comm>Special:MyLanguage/Communication</>|About communication]]</nowiki></code>.  
#: As example, instead of <code><nowiki>{{ll|Communication|About communication}}</nowiki></code>, better would be <code><nowiki>[[<tvar|comm>Special:MyLanguage/Communication</>|About communication]]</nowiki></code>.  
# Alternatively, may be exclude this code from translatable section and
# 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 <code> some text <nowiki>{{ll|Communication|About communication}}</nowiki> some text </code>, translation markup in translatable page will be  
#: As example, for <code> some text <nowiki>{{ll|Communication|About communication}}</nowiki> some text </code>, translation markup in translatable page will be:
#: <code><translation>some text</translation> <nowiki>{{ll|Communication|<translation>About communication</translation>}}</nowiki> <translation>some text</translation></code>.
#: <code><translation>some text</translation> <nowiki>{{ll|Communication|<translation>About communication</translation>}}</nowiki> <translation>some text</translation></code>.
#: This is useful for bulleted lists of links, e.g. in the "See also:" sections.
#: This is useful for bulleted lists of links, e.g., in the "See also:" sections.
# If link text does not have to be different from the name of landing page, will be better to embed all this code into <code><nowiki><tvar></nowiki></code>.
# 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 <code><nowiki><tvar></nowiki></code>.
#: As example, instead <code><nowiki>{{ll|Communication}}</nowiki></code>, translation markup in translatable page will be <code><nowiki><tvar|about-meta>{{ll|Communication}}</></nowiki></code>.
#: As example, instead of <code><nowiki>{{ll|Communication}}</nowiki></code> better would be <code><nowiki><tvar|about-meta>{{ll|Communication}}</></nowiki></code>.
 
== Source ==
Code taken from [https://www.mediawiki.org/wiki/Template:Localized_link Mediawiki - Template:Localized_link]


== See also ==
== See also ==
Line 69: Line 73:
<includeonly>
<includeonly>
<!-- Categories go here -->
<!-- Categories go here -->
 
[[Category:I18n]]
</includeonly>
</includeonly>

Latest revision as of 00:48, 7 April 2018

This is a documentation subpage for Template:Localized link .
It contains usage information, categories and other content that is not part of the original template page.

shortcut: Template:Ll

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

This is the TemplateData documentation for this template used by VisualEditor and other tools.

TemplateData for Localized link

Link to translatable page in the user's language. It uses the special page prefix "Special:MyLanguage/".

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Page name1

no description

Page namerequired
22 Custom label

no description

Default
Display title of linked page in the current page's language
Stringoptional

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:AboutProject:About
{{ll|Project:About|nsp=0}} AboutProject:About

Usage in translatable pages

On pages prepared for translation with the Translate extension, this template may be used in three ways.

  1. 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 ....
    As example, instead of {{ll|Communication|About communication}}, better would be [[Special:MyLanguage/Communication|About communication]].
  2. 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.
  3. 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 {{ll|Communication}}.

Source

Code taken from Mediawiki - Template:Localized_link

See also