Template:Assign property Has language
Template Assign property Has language:
- Assigns the appropriate "Has language::" property to the page in which it is used.
- Assigns a default sort key to the page, with the page name after the language code prefix.
This is the behaviour if the template is called without any parameters, and the page name of the current page (where the template is being used) applies.
If a pagename is passed in as first parameter, then the page's language and default sort key are printed, but not assigned. This feature is used below in the examples.
Contents
Use
{{Language code of page|optional page name}}
Examples
No page parameter
If no first parameter is passed in, the current page applies. This page has no language code, so nothing is returned.
{{Language code of page}}
{{#ifeq: {{#explode:assign property has language|{{#ifeq:template|file| |:}}|0}}
| {{#explode:assign property has language|{{#ifeq:template|file| |:}}|0}} | {{#ifeq: {{#explode:assign property has language|{{#ifeq:template|file| |:}}|0}} | {{#explode:assign property has language|{{#ifeq:template|file| |:}}|0}} | en| {{#explode:assign property has language|{{#ifeq:template|file| |:}}|0}}}}| {{#explode:assign property has language|{{#ifeq:template|file| |:}}|0}}}}
Page with a language code
{{Language code of page|Pt:Página principal}}
{{#ifeq: {{#explode:pt:página principal|{{#ifeq:|file| |:}}|0}}
| {{#explode:pt:página principal|{{#ifeq:|file| |:}}|0}} | {{#ifeq: {{#explode:pt:página principal|{{#ifeq:|file| |:}}|0}} | {{#explode:pt:página principal|{{#ifeq:|file| |:}}|0}} | en| {{#explode:pt:página principal|{{#ifeq:|file| |:}}|0}}}}| {{#explode:pt:página principal|{{#ifeq:|file| |:}}|0}}}}
{{Language code of page|De:Hauptseite}}
{{#ifeq: {{#explode:de:hauptseite|{{#ifeq:|file| |:}}|0}}
| {{#explode:de:hauptseite|{{#ifeq:|file| |:}}|0}} | {{#ifeq: {{#explode:de:hauptseite|{{#ifeq:|file| |:}}|0}} | {{#explode:de:hauptseite|{{#ifeq:|file| |:}}|0}} | en| {{#explode:de:hauptseite|{{#ifeq:|file| |:}}|0}}}}| {{#explode:de:hauptseite|{{#ifeq:|file| |:}}|0}}}}
{{Language code of page|Ar:مشاركة الأعمال الإبداعية 22}}
{{#ifeq: {{#explode:ar:مشاركة الأعمال الإبداعية 22|{{#ifeq:|file| |:}}|0}}
| {{#explode:ar:مشاركة الأعمال الإبداعية 22|{{#ifeq:|file| |:}}|0}} | {{#ifeq: {{#explode:ar:مشاركة الأعمال الإبداعية 22|{{#ifeq:|file| |:}}|0}} | {{#explode:ar:مشاركة الأعمال الإبداعية 22|{{#ifeq:|file| |:}}|0}} | en| {{#explode:ar:مشاركة الأعمال الإبداعية 22|{{#ifeq:|file| |:}}|0}}}}| {{#explode:ar:مشاركة الأعمال الإبداعية 22|{{#ifeq:|file| |:}}|0}}}}
Notice that the language code is searched firstly in the subpage name, and, if none is found, then searched in the pagename:
{{Language code of page|Case Studies/De:Breipott}}
{{#ifeq: {{#explode:case studies/de:breipott|{{#ifeq:|file| |:}}|0}}
| {{#explode:case studies/de:breipott|{{#ifeq:|file| |:}}|0}} | {{#ifeq: {{#explode:case studies/de:breipott|{{#ifeq:|file| |:}}|0}} | {{#explode:case studies/de:breipott|{{#ifeq:|file| |:}}|0}} | en| {{#explode:case studies/de:breipott|{{#ifeq:|file| |:}}|0}}}}| {{#explode:case studies/de:breipott|{{#ifeq:|file| |:}}|0}}}}
{{Language code of page|Ja:Flickr/Publish}}
{{#ifeq: {{#explode:ja:flickr/publish|{{#ifeq:|file| |:}}|0}}
| {{#explode:ja:flickr/publish|{{#ifeq:|file| |:}}|0}} | {{#ifeq: {{#explode:ja:flickr/publish|{{#ifeq:|file| |:}}|0}} | {{#explode:ja:flickr/publish|{{#ifeq:|file| |:}}|0}} | en| {{#explode:ja:flickr/publish|{{#ifeq:|file| |:}}|0}}}}| {{#explode:ja:flickr/publish|{{#ifeq:|file| |:}}|0}}}}
In particular, the language code in the subpage name has precedence:
{{Language code of page|Ja:Flickr/Pt:Publish}}
{{#ifeq: {{#explode:ja:flickr/pt:publish|{{#ifeq:|file| |:}}|0}}
| {{#explode:ja:flickr/pt:publish|{{#ifeq:|file| |:}}|0}} | {{#ifeq: {{#explode:ja:flickr/pt:publish|{{#ifeq:|file| |:}}|0}} | {{#explode:ja:flickr/pt:publish|{{#ifeq:|file| |:}}|0}} | en| {{#explode:ja:flickr/pt:publish|{{#ifeq:|file| |:}}|0}}}}| {{#explode:ja:flickr/pt:publish|{{#ifeq:|file| |:}}|0}}}}
Page without a language code
If a page parameter is passed in, but the page does not have a language code, nothing is returned (tested using this very page).
{{Language code of page|Template:Language code of page}}
{{#ifeq: {{#explode:language code of page|{{#ifeq:template|file| |:}}|0}}
| {{#explode:language code of page|{{#ifeq:template|file| |:}}|0}} | {{#ifeq: {{#explode:language code of page|{{#ifeq:template|file| |:}}|0}} | {{#explode:language code of page|{{#ifeq:template|file| |:}}|0}} | en| {{#explode:language code of page|{{#ifeq:template|file| |:}}|0}}}}| {{#explode:language code of page|{{#ifeq:template|file| |:}}|0}}}}
Category namespace
{{Language code of page|Category:Ksh:Övversäzongsprojäk}}
{{#ifeq: {{#explode:ksh:övversäzongsprojäk|{{#ifeq:category|file| |:}}|0}}
| {{#explode:ksh:övversäzongsprojäk|{{#ifeq:category|file| |:}}|0}} | {{#ifeq: {{#explode:ksh:övversäzongsprojäk|{{#ifeq:category|file| |:}}|0}} | {{#explode:ksh:övversäzongsprojäk|{{#ifeq:category|file| |:}}|0}} | en| {{#explode:ksh:övversäzongsprojäk|{{#ifeq:category|file| |:}}|0}}}}| {{#explode:ksh:övversäzongsprojäk|{{#ifeq:category|file| |:}}|0}}}}
File namespace
{{Language code of page|File:Pt Casos de estudo.png}}
{{#ifeq: {{#explode:pt casos de estudo.png|{{#ifeq:file|file| |:}}|0}}
| {{#explode:pt casos de estudo.png|{{#ifeq:file|file| |:}}|0}} | {{#ifeq: {{#explode:pt casos de estudo.png|{{#ifeq:file|file| |:}}|0}} | {{#explode:pt casos de estudo.png|{{#ifeq:file|file| |:}}|0}} | en| {{#explode:pt casos de estudo.png|{{#ifeq:file|file| |:}}|0}}}}| {{#explode:pt casos de estudo.png|{{#ifeq:file|file| |:}}|0}}}}