Template:Pg

From RobotX
Jump to navigation Jump to search
Template documentation[view] [edit] [history] [purge]

Render localized link to Commons/Help page name

Usage

{{pg |2= |1= }}

{{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

Button text
Lua error in Module:Autotranslate at line 72: No fallback page found for autotranslate (base=Template:TemplateDataInfo/i18n, lang=⧼lang⧽).

Syntax error in JSON.

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

⧼Seealso⧽

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.