This page is protected against editing.

Template:Pg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Template documentationview · edit · history · purge ]
This documentation is transcluded from Template:Pg/doc.

Render localized link to Commons/Help page name

Usage

{{pg |1= |2= }}

{{pg|pagename|displayname}}

Renders a link to a version of a target page in the Commons or Help namespace in the most suitable language that is available.

Target page selection

If the user is viewing a page in a language other than English and selects a link, they will be taken to a version of the target page in the same language if available, failing that in their preference language, and failing that in English.

  • If the current page language is English, {{pg|pagename}} renders [[pagename]]
  • If the current page language is e.g. French and there is a French version of the target page, renders e.g. [[pagename/fr|pagename]]
  • Otherwise renders e.g. [[Special:MyLanguage/pagename|pagename]]
    This will link to a version of the target page in the user's preferred language if available, or in English otherwise.

Display name

A display name will be used if provided. So {{pg|pagename|displayname}} renders e.g.

[[pagename|displayname]] or
[[pagename/fr|displayname]] or
[[Special:MyLanguage/pagename|displayname]]

If no display name is provided and the link is to a non-English page, the translated title of that page will be used if available. E.g., on a Spanish language page,

{{pg|Commons:Copyright rules by territory/Argentina}} renders
[[Commons:Copyright rules by territory/Argentina/es|Commons:Reglas de derechos de autor por territorio/Argentina]]

Anchor

The name of a section usually varies from one language to another, and may be changed. A link to a short capitalized {{Anchor}} on the target page will be more stable. The anchor can be placed outside the translatable part of the page to ensure that it is the same for all language versions, for example on Commons:File types as:

</translate>{{anchor|UNSUPP}}<translate>
===Unsupported file types===

A link to this anchor on a Spanish language page could be coded as:

{{pg|Commons:File types#UNSUPP|Tipos de archivo no soportados}}

which would render:

[[Commons:File types/es#UNSUPP|Tipos de archivo no soportados]]

If there was no Spanish version of the target page, it would render:

[[Special:MyLanguage/Commons:File types#UNSUPP|Tipos de archivo no soportados]]

Template parameters

<templatedata>JSON</templatedata> ./. {{TemplateBox}}
TemplateData

TemplateData is a way to store information about template parameters (the description of those and of the whole template) for both humans and machines. It is used by VisualEditor and possibly other tools like Upload Wizard.


Existing template documentation
At Wikimedia Commons, it is recommended to use {{TemplateBox}} with either ‎useTemplateData=1 or ‎useTemplateData=only on the ‎/doc subpage and transcluding it with {{Documentation}} into the template. ‎<nowiki>-tags can be wrapped around the arguments, if required, to avoid templates being expanded.

Newly created template documentation and imports
Another option, especially for imported templates, or for users with JSON experience, is placing raw ‎<templatedata>-tags into the Wikitext of the template, as described in various Wikipediae.

Discussion
There is an ongoing discussion about that matter. Feel invited to comment if you are experienced in either way, your time permits and if you like to share your opinion or to make a suggestion.


Wikipedia's help about TemplateDataCommons-specific information

Render localized link to Commons/Help page name

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
target1

Target page name, optionally including an anchor (i.e. “Page#Anchor”). Note that the anchor may be different in translations; either add an untranslatable anchor (see usage notes), or use the legacy parameter.

Linerequired
display name2

Override link text. By default the link text is the localized title of the linked page (except for Category, File and Special namespaces).

Lineoptional
anchoranchor

Name of anchor (or section) in the target page. Has the same effect as providing the anchor in page name, this parameter exists only for historical reasons.

Linedeprecated
languagelang

Language to link for. It’s needed only when using this template in other templates, it can automatically detect the language in Commons and Help namespaces. By default the page language for links to the Commons and Help namespaces, user language for other namespaces.

Lineoptional

Additional information

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

The template is intended to be used by the following user groups: all users

Relies on:
Module:Pg

See also

When a user is browsing through Commons or Help documentation, {{Pg}} tries to keep them on pages in their current selection of language as long as possible, falling back if needed to their preferred language and then to English. Thus a user who prefers a poorly supported language such as Asturian may choose to browse documentation in Spanish. {{Pg}} will link them from page to page in Spanish, while {{Localized link}} would repeatedly try to link to an Asturian version, fail, and fall back to English.

On the other hand, when a user is looking at a file description, they will see it in their preferred language if available, or English otherwise, because file descriptions and license templates are typically localized to preferred language using {{int:}}, {{De}}, {{PD-old-70}} etc. When the user clicks on a link in the file description it makes sense to take them to a target page in their preferred language if available, or English otherwise.

Localization

This template is not intended to be localized.