Difference between revisions of "Template:Assign property Has language"
Line 1: | Line 1: | ||
<includeonly><!-- | <includeonly><!-- | ||
− | -->{{#if:{{Language | + | -->{{#ifeq: {{#language:{{lc:{{#explode:{{SUBPAGENAME:{{{1|{{FULLPAGENAME}}}}}}}|{{#ifeq:{{NAMESPACE:{{{1|{{FULLPAGENAME}}}}}}}|{{ns:6}}| |:}}|0}}}}}} |
− | + | | {{lc:{{#explode:{{SUBPAGENAME:{{{1|{{FULLPAGENAME}}}}}}}|{{#ifeq:{{NAMESPACE:{{{1|{{FULLPAGENAME}}}}}}}|{{ns:6}}| |:}}|0}}}} | |
− | -->| [[Has language::{{ | + | | {{#ifeq: {{#language:{{lc:{{#explode:{{PAGENAME:{{{1|{{FULLPAGENAME}}}}}}}|{{#ifeq:{{NAMESPACE:{{{1|{{FULLPAGENAME}}}}}}}|{{ns:6}}| |:}}|0}}}}}} |
+ | | {{lc:{{#explode:{{PAGENAME:{{{1|{{FULLPAGENAME}}}}}}}|{{#ifeq:{{NAMESPACE:{{{1|{{FULLPAGENAME}}}}}}}|{{ns:6}}| |:}}|0}}}} | ||
+ | | {{#if:{{{1|}}} | ||
+ | | Language: {{CONTENTLANGUAGE}} - Default sort key: None<!-- | ||
+ | -->| [[Has language::{{CONTENTLANGUAGE}}| ]]<!-- | ||
+ | -->}}<!-- | ||
+ | -->| {{#if:{{{1|}}} | ||
+ | | Language: {{lc:{{#explode:{{PAGENAME:{{{1|{{FULLPAGENAME}}}}}}}|{{#ifeq:{{NAMESPACE:{{{1|{{FULLPAGENAME}}}}}}}|{{ns:6}}| |:}}|0}}}} - <!-- | ||
+ | -->Default sort key: {{#explode:{{PAGENAME:{{{1|{{FULLPAGENAME}}}}}}}|{{#ifeq:{{NAMESPACE:{{{1|{{FULLPAGENAME}}}}}}}|{{ns:6}}| |:}}|1}}<!-- | ||
+ | | [[Has language::{{lc:{{#explode:{{PAGENAME:{{{1|{{FULLPAGENAME}}}}}}}|{{#ifeq:{{NAMESPACE:{{{1|{{FULLPAGENAME}}}}}}}|{{ns:6}}| |:}}|0}}}}| ]]<!-- | ||
+ | -->{{DEFAULTSORT:{{#explode:{{PAGENAME:{{{1|{{FULLPAGENAME}}}}}}}|{{#ifeq:{{NAMESPACE:{{{1|{{FULLPAGENAME}}}}}}}|{{ns:6}}| |:}}|1}}}}<!-- | ||
+ | -->}}<!-- | ||
+ | -->}}<!-- | ||
+ | -->| {{#if:{{{1|}}} | ||
+ | | Language: {{lc:{{#explode:{{SUBPAGENAME:{{{1|{{FULLPAGENAME}}}}}}}|{{#ifeq:{{NAMESPACE:{{{1|{{FULLPAGENAME}}}}}}}|{{ns:6}}| |:}}|0}}}} - <!-- | ||
+ | -->Default sort key: {{#explode:{{SUBPAGENAME:{{{1|{{FULLPAGENAME}}}}}}}|{{#ifeq:{{NAMESPACE:{{{1|{{FULLPAGENAME}}}}}}}|{{ns:6}}| |:}}|1}}<!-- | ||
+ | -->| [[Has language::{{lc:{{#explode:{{SUBPAGENAME:{{{1|{{FULLPAGENAME}}}}}}}|{{#ifeq:{{NAMESPACE:{{{1|{{FULLPAGENAME}}}}}}}|{{ns:6}}| |:}}|0}}}}| ]]<!-- | ||
+ | -->{{DEFAULTSORT:{{#explode:{{SUBPAGENAME:{{{1|{{FULLPAGENAME}}}}}}}|{{#ifeq:{{NAMESPACE:{{{1|{{FULLPAGENAME}}}}}}}|{{ns:6}}| |:}}|1}}}}<!-- | ||
+ | -->}}<!-- | ||
-->}}</includeonly><noinclude> | -->}}</includeonly><noinclude> | ||
− | Template '''{{PAGENAME}}''' | + | Template '''{{PAGENAME}}''': |
+ | |||
+ | * Assigns the appropriate "Has language::" property to the page in which it is used. | ||
+ | * Assigns a default [http://www.mediawiki.org/wiki/Help:Categories#Sort_key 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.''' | ||
+ | |||
+ | ==Use== | ||
+ | <pre> | ||
+ | {{Language code of page|optional page name}} | ||
+ | </pre> | ||
+ | |||
+ | ==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. | ||
+ | <pre> | ||
+ | {{Language code of page}} | ||
+ | </pre> | ||
+ | {{Language code of page}} | ||
+ | |||
+ | ===Page with a language code=== | ||
+ | <pre> | ||
+ | {{Language code of page|Pt:Página principal}} | ||
+ | </pre> | ||
+ | {{Language code of page|Pt:Página principal}} | ||
+ | |||
+ | <pre> | ||
+ | {{Language code of page|De:Hauptseite}} | ||
+ | </pre> | ||
+ | {{Language code of page|De:Hauptseite}} | ||
+ | |||
+ | <pre> | ||
+ | {{Language code of page|Ar:مشاركة الأعمال الإبداعية 22}} | ||
+ | </pre> | ||
+ | {{Language code of page|Ar:مشاركة الأعمال الإبداعية 22}} | ||
+ | |||
+ | Notice that the language code is searched firstly in the subpage name, and, if none is found, then searched in the pagename: | ||
+ | <pre> | ||
+ | {{Language code of page|Case Studies/De:Breipott}} | ||
+ | </pre> | ||
+ | {{Language code of page|Case Studies/De:Breipott}} | ||
+ | |||
+ | <pre> | ||
+ | {{Language code of page|Ja:Flickr/Publish}} | ||
+ | </pre> | ||
+ | {{Language code of page|Ja:Flickr/Publish}} | ||
+ | |||
+ | In particular, the language code in the subpage name has precedence: | ||
+ | <pre> | ||
+ | {{Language code of page|Ja:Flickr/Pt:Publish}} | ||
+ | </pre> | ||
+ | {{Language code of page|Ja:Flickr/Pt:Publish}} | ||
+ | |||
+ | ===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). | ||
+ | <pre> | ||
+ | {{Language code of page|Template:Language code of page}} | ||
+ | </pre> | ||
+ | {{Language code of page|Template:Language code of page}} | ||
+ | |||
+ | ===Category namespace=== | ||
+ | <pre> | ||
+ | {{Language code of page|Category:Ksh:Övversäzongsprojäk}} | ||
+ | </pre> | ||
+ | {{Language code of page|Category:Ksh:Övversäzongsprojäk}} | ||
+ | |||
+ | ===File namespace=== | ||
+ | <pre> | ||
+ | {{Language code of page|File:Pt Casos de estudo.png}} | ||
+ | </pre> | ||
+ | {{Language code of page|File:Pt Casos de estudo.png}} | ||
[[Category:Support translation templates|{{PAGENAME}}]] | [[Category:Support translation templates|{{PAGENAME}}]] | ||
</noinclude> | </noinclude> |
Revision as of 02:51, 27 April 2011
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}}}}