Zum Inhalt springen

Modul:languages/templates/Doku

Vun Wiktionary

Dies ist die Dokumentationsseite für Modul:languages/templates

This module provides access to Module:languages from templates, so that they can make use of the information stored there.

Exported functions

[ännern]

exists

[ännern]

{{#invoke:languages/templates|exists|(language code)}}

Check whether a language code exists and is valid. It will return "1" if the language code exists, and the empty string "" if it does not.

This is rarely needed, because a script error will result when someone uses a code that is not valid, so you do not need this just to check for errors. However, in case you need to decide different actions based on whether a certain parameter is a language code or something else, this function can be useful.

getByCode

[ännern]

{{#invoke:languages/templates|getByCode|(language code)|(item to look up)|(index)}}

Queries information about a language code.

  • The language code should be one of the codes that is defined in Module:languages data. If it is missing or does not exist, the result will be a script error.
  • The item is the name of one of the functions of a language object, such as getCanonicalName or getScripts. If no item has been provided, the result will be a script error.
  • The index is optional, and is used for items that are lists, such as getAllNames or getScripts. It selects which item in the list to return. On items that are single strings, like getFamily, it has no effect. If an index is given that is higher than the number of items in the list, the result will be an empty string.

For example, to request the default (canonical) name of the language whose code is en:

{{#invoke:languages/templates|getByCode|en|getCanonicalName}}
  • Result: Engelsch

To request its second name, if any:

{{#invoke:languages/templates|getByCode|en|getAllNames|2}}
  • Result: English

To request its family:

{{#invoke:languages/templates|getByCode|en|getFamily}}
  • Result: gmw

See also

[ännern]