User:Wynndale/langcode
Script error: No such module "Sandbox/Wynndale".
Note to editors: Please don't categorize this template by editing it directly. Instead, place the category in its documentation page, in its "includeonly" section.
Usage
This template extracts the ISO 639 language identifier from the page name. Call simply as {{langcode}}. To keep compatibility with templates that use the {{langcode|{{{lang|}}}}} syntax this template returns its first argument if given. Note that this stops Mediawiki from caching the page, but this template is more optimised than older versions. Non-language prefixes such as Key:, Tag: and Relation: are handled correctly. Pages without a colon in the name are reported as English although local project pages may not be.
Implementation
The arguments to #invoke are pseudonamespace/language pairs, for instance Key=en means that pages with names beginning with Key: are in English. Prefixes such as Pt: directly corresponding to languages do not have to be added here because the Scribunto module returns the beginning of the page name in lower case if it doesn’t match any of the arguments.