Template:language data documentation

Sabdkosh se

This module contains definitions and metadata for language codes. See Wiktionary:Languages for more information.

This module must not be used directly in other modules or templates. The data should be accessed through Module:languages.

Errors[badlo]

Module:data consistency check shows no relevant errors.

Required values[badlo]

Every entry in the table must contain the following indexed fields:

1
The "canonical" name of the language. This is the name that is used in Wiktionary entries and category names.
2
The Wikidata item id (Q number) for the language. Can be specified as a number (a positive integer) or a string that starts with Q and ends with decimal digits. Set to nil if not known/present. This replaces the older wikipedia_article property, which can still be used to link to specific sections or language editions.

Optional values[badlo]

3
The code for the family that the language belongs to. See Wiktionary:Families.
4
A list of script codes, see Wiktionary:Scripts. These represent all the scripts (writing systems) that this language uses in the real world, as well as the ones that Wiktionary uses. The scripts that are used most often on Wiktionary should be first in the list, as this will speed up script detection.
Many templates and modules detect the script of text in a particular language using the findBestScript function in Module:scripts. This function goes down the list of scripts and counts how many characters in the text belong to each script. If all the characters belong to one script, that script will be returned; otherwise, the script with the most characters will be returned. Thus, script detection will be faster if the most frequently used scripts are first in the list.
display_text
Defines replacements to create the display form of the text, which is the form actually displayed on the page. This is occasionally necessary if there is a recurring issue of editors adding the wrong character, which is sometimes an issue when two or more characters are easy to confuse. For example, the palochka ӏ, used in Cyrillic in many Caucasian languages, is frequently entered as I, or even Latin l or I. As this is an ongoing issue (even among native speakers), the easiest way to solve the problem is to automatically correct the display form for those languages. This is used by makeDisplayText in Module:languages.
entry_name
Defines replacements to create the entry name from the displayed form of a term. This can be used to remove certain diacritical marks according to the customs or standard practice of the language. For example, it is used to remove accent marks from Russian words (ру́сскийрусский), or macrons from Latin or Old English words (ōsos), as these are not used in the normal written form of these languages. This is used by makeEntryName in Module:languages.
sort_key
Defines replacements to create a category sort key from the page name. The purpose is to:
  1. Remove any characters that should be ignored in sorting.
  2. Replace characters with other characters, if the sorting rules for that language do not distinguish them. For example, in German, the characters "ä" and "a" are considered equivalent for sorting, and are both treated as "a".
  3. Replace characters that should be sorted in different places with special characters that mimic that behaviour, (which is necessary due to MediaWiki software using the Unicode codepoint to determine sort order, which is often arbitrary). For instance, in Mongolian, the character "ү" should be sorted after "у", but due to its codepoint it is sorted after "я" by default. As such, we can replace "ү" with "у" plus a character with a very high codepoint, which ensures that it is always sorted straight after.

The page name is converted to lowercase before applying the replacements, so you should not add uppercase letters to the "from" lists. This is used by makeSortKey in Module:languages.

display_text, entry_name and sort_key work via text substitution: they replace or remove certain characters (or sets of characters) for particular contexts. They each work in the same way, and are all optional. Each can either be a table (containing substitutions as outlined below), or the name of a module which processes generates the output independently (e.g. if the procedure is too complex for the procedure below, if certain diacritics must be removed in one script but not another, or as a way to keep a group of languages synchronised by pointing them all at the same module).

If display_text is the name of a module (for instance, "cau-displaytext" referring to Module:cau-displaytext), the module must contain a display text generating function that is named makeDisplayText. This function must take the arguments text, lang, sc, where text is the input text (usually the page name or input by the user), lang is the language code (not the language object), and sc is the script code (not the script object). The returned value should always be the desired display text as a string, or there will be a module error in the Language:makeDisplayText() function.

If entry_name is the name of a module (for instance, "ar-entryname" referring to Module:ar-entryname), the module must contain a entry name generating function that is named makeEntryName. This function must take the arguments text, lang, sc, where text is the input text (usually the page name or input by the user), lang is the language code (not the language object), and sc is the script code (not the script object). The returned value should always be the desired entry name as a string, or there will be a module error in the Language:makeEntryName() function.

If sort_key is the name of a module (for instance, "zh-sortkey" referring to Module:zh-sortkey), the module must contain a sortkey-generating function that is named makeSortKey. This function must take the arguments text, lang, sc, where text is the input text (usually the page name or input by the user), lang is the language code (not the language object), and sc is the script code (not the script object). The returned value should always be the desired sortkey as a string, or there will be a module error in the Language:makeSortKey() function.

If display_text, entry_name or sort_key is a table, it should have one of the following combinations of subfields:

  1. from and to.
  2. remove_diacritics (and optionally remove_exceptions).
  3. Both of the above.

from is paired with to, and both of them must be tables that are organised pairwise: each element in from is a pattern to identify which characters in the term to replace, while the corresponding element in to defines what to replace them with (as arguments to mw.ustring.gsub).

If the replacement is not present (or if it is false or nil), then any matching characters are removed altogether. This means that the from list can be longer than the to list, and an empty replacement will be assumed for any elements in from that have no counterpart in to.

The tables can contain literal characters, or the patterns (a simplified form regular expressions) that are used by the standard Scribunto mw.ustring.gsub function. See the Scribunto reference manual for more information.

display_text, entry_name and sort_key can also contain a remove_diacritics string, which contains characters that will be removed after the text is decomposed. For instance, if remove_diacritics is a combining acute accent, all acute accents will be stripped, even if they are part of precomposed characters (like á or ά). Despite the name, the characters to be stripped need not be diacritics: for instance, including an apostrophe would remove all apostrophes (though be careful with hyphens, which must be be escaped with %).

Furthermore, if display_text, entry_name or sort_key contain remove_diacritics, they can also contain a remove_exceptions table, which prevents specific characters from having their diacritics stripped. For instance, if remove_diacritics is a combining diaeresis, but remove_exceptions contains "ё", then any instances of ё will remain unchanged. On the other hand, an instance of ӱ would still become у (unless "ӱ" is also added to remove_exceptions).

At the top of the module, there is a list of combining characters with names. These are provided for convenience and readability, as combining characters generally do not display properly inside the module code (though they are still interpreted correctly by the module).

These are other optional values:

type
The type of language (which affects how it is handled on Wiktionary). Possible values are:
  • regular - This value is the default, so it doesn't need to be specified. It indicates that the is attested according to WT:CFI and therefore permitted in the main namespace. There may also be reconstructed terms for the language, which are placed in the Reconstruction namespace and must be prefixed with * to indicate a reconstruction.
  • reconstructed - This language is not attested according to CFI, and therefore is allowed only in the Reconstruction namespace. All terms in this language are reconstructed, and must be prefixed with *.
  • appendix-constructed - This language is attested but does not meet the additional requirements set out for constructed languages (WT:CFI#Constructed languages). Its entries must therefore be in the Appendix namespace, but they are not reconstructed and therefore should not have * prefixed in links.
translit
The name of a module that is used to generate transliterations of terms, without the Module: prefix. This module must export a function named tr that is defined as follows:
tr(text, lang, sc)
The three parameters are the text to be transliterated, the language code, and the script code. The function can ignore the language and script codes, but they are provided for cases when a language has more than one script, or when a single function is used to transliterate multiple languages sharing the same script.
ancestors
A table listing the language codes of the direct ancestors of this language. For example, the ancestor of English is listed as enm (Middle English); ang (Old English, the ancestor of Middle English), gem-pro (Proto-Germanic, the ancestor of Old English), and ine-pro (Proto-Indo-European, the ancestor of Proto-Germanic) are not listed.
For most languages, only one ancestor code should be given, but multiple ancestors can be listed for pidgins, creoles and mixed languages.
The ancestor language table should not be included if the language's direct ancestor is the proto-language of the family to which the language belongs. In such a case, if the family code has been provided, Module:languages will automatically add the proto-language as the language's ancestor. For example, Proto-Germanic (gem-pro) belongs to the Indo-European (ine) family, and its direct ancestor is Proto-Indo-European (ine-pro). Because Proto-Indo-European is the proto-language of the Indo-European languages, Proto-Germanic does not need an ancestors table; Proto-Indo-European will be automatically returned as its ancestor by the getAncestors function.
wikimedia_codes
A table listing the Wikimedia language codes that this language maps to. This is used to translate Wiktionary codes to Wikimedia codes, which are usually the same but there are a few languages where it is different. The language codes must be valid Wikimedia codes (as determined by the wiki software), and if they are not defined in one of the language data modules, they must be defined in Module:wikimedia languages/data.
wikipedia_article
The name of the Wikipedia article for the language. Should normally only be supplied if the Wikidata id cannot be used.
link_tr
Set this to true to link the language's transliteration. For instance, Gothic has entries in Gothic script and entries for transliterations: 𐌷𐌻𐌰𐌹𐌱𐍃 (hlaibs).
dotted_dotless_i
Set this to true for languages that distinguish between the dotted and dotless I (such as some Turkic languages).

Formerly supported values[badlo]

aliases, varieties, otherNames
This data is now located in the extra data modules; see Module:languages and Template:language extradata documentation.
family
Now 3.
scripts
Now 4.

Script error: The function "main" does not exist.