Module:Languages/config/doc

From OpenStreetMap Wiki
Jump to navigation Jump to search

This is a data module that contains configuration for Module:Languages.

Usage

The module exports only simple types, so it can be loaded as a data module:

mw.loadData("Module:Languages/config")

Module:Languages is used by templates that are transcluded many times on a given page, so loading this module as a data module helps to avoid wasteful Lua processing.

Structure

languageNamesByCode

The languageNamesByCode table has ISO 639 language codes as keys and autonyms (native names) as values. Module:Languages uses this table to label language links. The table is derived from MediaWiki's internal localization data, which has several inaccuracies for historical reasons. If the table is missing a language code that is used on this wiki or the name of a language is incorrect, modify languageNamesByCode after the call to mw.language.fetchLanguageNames().

languageCodes

The languageCodes table contains the ISO 639 language codes of languages used on this wiki, sorted by the languages' autonyms (native names). Module:Languages uses this table to arrange the list of links. The list appears on almost every page on this wiki, so it should be as short as possible.

A language code may be included only if this wiki has at least one content page in the language, based on the page title (which should contain the language code either as a namespace or a pseudonamespace). Empty categories and redirects alone are insufficient for a language to be listed. The codes pt-br, ro-md, and zh-tw are deprecated and thus omitted, even though a few content pages remain under those pseudonamespaces.

If languageCodes is missing a language code that is used on this wiki or the language is misplaced in the list:

  1. Add the missing language code anywhere in the languageCodes table.
  2. Remove the language code from minorLanguageCodes.
  3. Enter p.languageCodesSortedByName() in the debug console below the source code editor, then press Enter.
  4. Copy and paste the result into the source code editor, replacing the languageCodes table's previous contents.

If a language code in languageCodes is no longer used on this wiki, remove it from languageCodes and add it to minorLanguageCodes (if the language code is still valid) or deprecatedLanguageCodes (if the language code is invalid and should not be used anymore).

languageCodesSortedByName

This function sorts the contents of languageCodes by autonym, then logs the sorted table to the debug console. This function is only available in the debug console. It is not exported to any other module or template, because the NFD normalization required for Unicode-aware sorting is very memory-intensive.

See also