Template:CURRENTCONTENTLANGUAGE

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

en

Template documentationview · edit · history · purge ]

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 {{CONTENTLANGUAGE}} (the default content language; on this wiki: "en" for English).

Usage

{{CURRENTCONTENTLANGUAGE}}

This template is largely superseded by the {{PAGELANGUAGE}} magic word; however, the two work differently: this template uses the page title, while the magic word uses the page content language. The two are same for pages translated using the Translate extension (except for the translation original if it’s not English—this template expects that translation originals are always English), but this template also works on pages that don’t use the Translate extension but do use language codes in page names (this is very rare on Commons outside of the template namespace, manually translated pages usually have translated titles); on the other hand, the magic word also works when the page language has been manually set by a translation administrator even if the page title doesn’t end with a language code, for example on some translated main pages.

The template takes no parameters.

Additional information

The template is intended to be used in the following namespaces: the Template namespace

The template is intended to be used by the following user groups: all users

Localization

This template is not intended to be localized.

Examples

  • on "Bar/foo", this template returns "en";
  • on "Bar/foo/hu", this template returns "hu".

(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.)