Difference between revisions of "Template:Language code of page"

From Creative Commons
Jump to: navigation, search
Line 18: Line 18:
 
==Examples==
 
==Examples==
 
===No page parameter===
 
===No page parameter===
If no first parameter is passed in, the current page applies.
+
If no first parameter is passed in, the current page applies. This page has no language code, so nothing is returned.
 
<pre>
 
<pre>
 
{{Language code of page}}
 
{{Language code of page}}
Line 29: Line 29:
 
</pre>
 
</pre>
 
{{Language code of page|Pt:Página principal}}
 
{{Language code of page|Pt:Página principal}}
 +
 +
<pre>
 +
{{Language code of page|De:Hauptseite}}
 +
</pre>
 +
{{Language code of page|De:Hauptseite}}
  
 
===Page without a language code===
 
===Page without a language code===
If no first parameter is passed in, the current page applies.
+
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>
 
<pre>
 
{{Language code of page|Template:Language code of page}}
 
{{Language code of page|Template:Language code of page}}

Revision as of 10:51, 21 April 2011

Template Language code of page returns the language code of a page. If no page name is passed in as the first parameter, the current page (in which it is being used) applies. If there is no language code, it returns empty.

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: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}}}}

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

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