Template:Lang2iso/doc

From blackwiki
< Template:Lang2iso
Revision as of 12:52, 18 September 2020 by imported>Gonnym (→‎Purpose)
Jump to navigation Jump to search

Template:Lang2iso, should not be transcluded directly from article namespace. Template:Lang2iso takes an English-language language name (such as "Abkhazian" or "Sinhalese") and converts it into a two-letter ISO 639 language code. This table's values are based on List of ISO 639-1 codes.

Examples

  • {{Lang2iso|German}} returns "de"
  • {{Lang2iso|Greek}} returns "el"
  • {{Lang2iso|Spanish}} returns "es"

Purpose

Since most users will know a language's name but not its ISO code, this template/macro is meant to facilitate invocations of other templates such as Template:Lang. Thus, instead of recalling (or having to know) that the ISO code for German is "de" and transcluding:

{{lang|de|Mädchen}}

one can type:

{{lang|{{subst:lang2iso|German}}|Mädchen}}

This also reduces the number of parameters that need to be passed to some language routines (such as those similar to Template:Language with name) since the ISO Language Code can now be derived from the ISO Language Name.

See also