Template:WikiLink

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Help:Link

Template documentationview · edit · history · purge ]
This documentation is transcluded from Template:WikiLink/doc.

Renders a link to the article name in Wikipedia corresponding to a Wikidata QID

Usage

{{WikiLink |qid= |lang= |display= |notfound= }}

Links to the article in the preferred language if available, or in English if not. As a fallback, links to the Wikidata entry. If available, the Wikidata label name in the target language is shown if the display name is not given. Usually, but not always, this is the same as the name of the article in the target Wikipedia. There are exceptions. For example, as of June 2019

  • The Wikidata English label for Q180 was Wikimedia Foundation, Inc., while the Wikipedia:en name was Wikimedia Foundation.
  • The Wikidata English label for Q861013 was Image copyright, while the Wikipedia:en name was Photograph copyright (Germany).
  • The Wikidata Chinese label for Q22668 was 最小惊讶原则, but there was no Chinese Wikipedia entry
  • The Wikidata English label for Q314956 was right to image, but there was no English Wikipedia entry

If there is no translation of the Wikidata label into the target language the default version is given, usually English.

Typically this template is called from a "container" template such as {{Wp-Public domain}}. The advantage over hard coded links like [[w:en:pagename]] or {{w|pagename||en}} is that translators do not have to check what the target page is called in their language, or even whether it exists in their language. The link will start to point to a version in their language as soon as that version is created. The drawback is that a container template is needed for each Wikidata label to map from the target name to its QID, similar to a multilingual tag for a location.

Template parameters

ParameterDescriptionDefaultStatus
qidQidWikidata identifieremptyrequired
langlanguageLanguage to link Wikipedia in (and show label in, if not overridden)enoptional
displaylink textName to display in the linkTranslated Wikidata labeloptional
notfoundno translation warningText to add in brackets parentheses if request language was not English, but link is to English versionemptyoptional
Template data
<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

Renders a link to the article name in Wikipedia corresponding to a Wikidata QID

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
link textdisplay

Name to display in the link

Default
Translated Wikidata label
Lineoptional
languagelang

Language to link Wikipedia in (and show label in, if not overridden)

Default
en
Lineoptional
no translation warningnotfound

Text to add in brackets parentheses if request language was not English, but link is to English version

Lineoptional
Qidqid

Wikidata identifier

Linerequired

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:

See also

Localization

This template is not intended to be localized.

Examples

Code Result
{{WikiLink|qid=Q180}} Wikimedia Foundation
{{WikiLink|qid=Q180|display=abc}} abc
{{WikiLink|qid=Q180|lang=ar}} مؤسسة ويكيميديا
{{WikiLink|qid=Q180|lang=ar|display=abc}} abc
{{WikiLink|qid=Q180|lang=ar|notfound=in English}} مؤسسة ويكيميديا
{{WikiLink|qid=Q5578397}} Golan v. Holder
{{WikiLink|qid=Q5578397|lang=vo}} Golan v. Holder
{{WikiLink|qid=Q5578397|lang=vo|notfound=in English}} Golan v. Holder [in English]