Template:CURRENTCONTENTLANGUAGE: Difference between revisions

Content added Content deleted
(small generalization)
(more robust: it checks against the known language codes)
Line 1: Line 1:
<includeonly>{{#ifeq:{{#language:{{SUBPAGENAME}}}}|{{lc:{{SUBPAGENAME}}}}|{{CONTENTLANGUAGE}}|{{SUBPAGENAME}}}}</includeonly><noinclude>This template returns the "content language" of the current page; more precisely it checks if the current title ends with a language code, and if it is the case it returns this language code, else &#123;{CONTENTLANGUAGE}} (the default content language; on this wiki: "{{CONTENTLANGUAGE}}" for {{#language:{{CONTENTLANGUAGE}}|en}}).
<includeonly>{{#if:{{#invoke:Template translation|getLanguageSubpage}}|{{#invoke:Template translation|getLanguageSubpage}}|{{CONTENTLANGUAGE}}}}</includeonly><noinclude>This template returns the "content language" of the current page; more precisely it checks if the current title ends with a language code, and if it is the case it returns this language code, else &#123;{CONTENTLANGUAGE}} (the default content language; on this wiki: "{{CONTENTLANGUAGE}}" for {{#language:{{CONTENTLANGUAGE}}|en}}).


Examples:
Examples:
* on "Bar/foo", this template returns "{{CONTENTLANGUAGE}}";
* on "Bar/foo", this template returns "{{CONTENTLANGUAGE}}";
* on "Bar/foo/hu", this template returns "hu".
* on "Bar/foo/hu", this template returns "hu".
(Note: on "Foo/bar" it returns "bar" because "bar" is the language code for Bavarian; "foo" is not a language code; very small (2 or 3 letters) last words can be a problem as seen here.)
(Note: there could be false positive: e.g. on "Foo/bar" it returns "bar" because "bar" is the language code for Bavarian; "foo" is not a language code; very small (2 or 3 letters) last words can be a problem as seen here.)


This template takes no argument, and acts as a magic word. If such a magic word is created in MediaWiki, this template could be deleted. Note that the definition of "content language" here is broader than the (page-specific) content language in MediaWiki, which can currently only be set by the Translate extension or some very special pages.
This template takes no argument, and acts as a magic word. If such a magic word is created in MediaWiki (see [[bugzilla:57603]]), this template could be deleted.


[[Category:Translation templates]]</noinclude>
[[Category:Translation templates]]</noinclude>