Template:Relation

From OpenStreetMap Wiki
(Redirected from Template:De:Relation)
Jump to navigation Jump to search
[Edit] [Purge] Template-info.svg Template documentation

exclamation mark

Note: This template is used on a lot of pages. In order not to put too much load on the servers, edits should be kept to a bare minimum.
Please discuss proposed changes on the talk page first.
Editing a template causes all pages that use the template to be re-rendered. If the Template is used often, this can put a lot of load on the servers since it fills up the job queue. [statistics]

This page documents the features of the templates {{Area}}, {{Node}}, {{Relation}}, and {{Way}}. These templates can be used for inserting links to either nodes, ways, or relations (area links to a closed way) as well as tool links. All templates share a common codebase. Therefore, they work almost identical ({{Area}} and {{Relation}} have each a minor difference to the rest).
It was rewritten in Autumn 2018 using fewer options and Lua.

Usage

The usage is similar for all templates described here. You just have to adjust the name (e.g. {{Area|...}} instead of {{Node|...}}). Writing

{{node|12345}}

results in

node 12345

Overview of all parameters:

Name/Number Possible values Description
1 Integer refers to an OSM ID, required parameter
2 String label for the main link, default: same as ID
tools all, josm, mini, no, or short tool links to be displayed, default: no(ne)
lang language code from Mediawiki's list or special code in this wiki used to assure the labelling of the links in a certain language (see section Translation below)

Feature list

Wiki code Result Note
{{Relation|2345}} relation 2345 The icon links to the wiki article about relations.
{{Relation|2345|Promenade}} relation Promenade
{{Relation|2345|tools= all }} relation 2345 (iD JOSM history analyse)
{{Relation|2345|tools= all |Promenade}} relation Promenade (iD JOSM history analyse)
{{Relation|2345|tools= all |lang= vi }} relation 2345 (iD JOSM lịch sử phân tích) translation to Vietnamese
{{Relation|2345|Promenade|tools= all |lang= ar }} relation Promenade (iD JOSM التاريخ analyse) Help translate this to Arabic translation falls back to English as Arabic translation is incomplete.
{{Way|12346|tools= all |lang= ar }} way 12346 (iD JOSM التاريخ) links displayed depending on the element
{{Relation|2345|tools= josm }} relation 2345 (JOSM)
{{Relation|2345|tools= josm |Promenade}} relation Promenade (JOSM)
{{Relation|2345|tools= mini }} 2345
{{Relation|2345|tools= mini |Promenade}} Promenade
{{Relation|2345|tools= no }} relation 2345
{{Relation|2345|tools= no |Promenade}} relation Promenade
{{Relation|2345|tools= short }} 2345 (i J)
{{Relation|2345|tools= short |Promenade}} Promenade (i J)
{{Relation||Promenade}} Lua error in Module:Element at line 60: Given relation id parameter is not a number. Does not work, ID required.

Translation

If the parameter tools is set to all, the link labelled history will be shown. In case of {{Relation}} there is an additional link analyse. Their labels will align themselves to the page language. There is also a lang parameter for explicitly setting the language. Extracting the language of a page seems to be an expensive process (for the parser which takes longer to create the page). Unfortunately, this is also repeated for every occurrence of the template even on the same page. Therefore, translations are limited to a minimum (i.e. there is a translation with tools=all only).

lang parameter

The lang parameter is used to explicitly request a translated version of the template. It translates two English texts ("analyse" and "history"). These are used with the setting tools=all only. It also adds the prefix for the link to the article "relation" (below the icon) regardless of its existence. Whilst the language is automatically detected, the link will not change without request. This is due to the fact that the icon's wikicode is generated before the language version may be detected.

Languages for Translation

The module stores all translations in Module:Element/translation. There are the following priorities for examining the correct language:

  1. user input in lang parameter
  2. dedicated language namespace (DE, ES, FR, IT, JA, NL, RU)
  3. language title prefix (all other prefixes)
  4. English as default

This means that there is no specified fallback language used apart from English.
The templates {{Hu:Relation}}, {{Pl:Relation}} and {{Pt:Relation}} are versions of this template which fall back to Hungarian, Polish and Portuguese if no user input is provided.

Adding a Language

Please paste the following lines into the code of Module:Element/translation:

 translateAnalyse = {
 	-- other language codes alphabetically before 'code'
 	['code'] = "your translation",
 	-- other language codes alphabetically after 'code'
 },
 translateHistory = {
 	-- other language codes alphabetically before 'code'
 	['code'] = "your translation",
 	-- other language codes alphabetically after 'code'
 },

Missing language

If there is no complete translation, the page is also added to one of the subcategories of Category:Pages with missing translation. This is useful for finding missing translations in this wiki. The language name is read from Module:OSM Constants or mw.language.fetchLanguageName(pageLanguage, 'en').

Design Decisions

This section aims to explain why this template works this way. It should be read before proposing any changes. There may be different opinions (see Discussion page), but this documentation only focuses on the current implementation.

Why are the tools not shown by default?
This is simply too "expensive" (see translation). This setting would result in many pages being displayed in maintenance categories like Category:Pages where template include size is exceeded. It would also assume that everyone using this template (think of a mapper fixing a wiki error without wiki background) wants to have all tools available.
Why are there so few tools only?
This is a general purpose template, if you need special links, you can add them directly to your page. Please remember that the parser is not able to cache this template, so if you link to five relations, it has to create 35 (= 5 * 7) links in the worst case (i.e. displaying all tools).
Why was the "undefined relation" option dropped?
Simply because it fails its purpose: This template is for linking to a relation, if there is no relation (yet) you can simply leave out this template (this is commonly done now anyway). This would be like a link to a web page with an "under construction" banner only. In addition, as it displayed text, it had to compute the page language and translate the text for every call, a functionality that can be archived at lower cost by inserting the text itself.
Why is there no "status"?
Template:State provides a more detailed way of documenting mapping statuses.
Why are shortened URLs used instead of the long forms?
There are pages that include this template over 1000 times. Replacing short URLs like osm.org with openstreetmap.org would increase the size of the expanded text by 11 characters. The change would scale up to 11,000 characters in such an article. There are also options which use multiple links, this would result in an even bigger increase.


This template renders link to specified relation with possible extra tools.

Template parameters

ParameterDescriptionTypeStatus
Relation id1

Relation id (number).

Numberrequired
Label for rendering2

Label to render instead of relation id

Lineoptional
Linked toolstools

Tools linked next to relation link.

Suggested values
all mini short no
Lineoptional
Languagelang

Language of rendered template.

Example
de
Stringoptional