Module:Languages/doc

From OpenStreetMap Wiki
Jump to navigation Jump to search

This module provides utilities for working with languages and language names. Most notably, it powers {{Languages}}, the language bar at the top of almost every page of this wiki.

sourceTitle

Returns the title of the source page corresponding to the given page name. If the page name is not specified as the first argument, then the current page name is used. In a set of translated pages that covers the same topic, the source page is the page written in the wiki's default content language, English.

A number of testcases verify the correctness of this function. Run the unit tests.

languages

Returns a flat list of links to translations of the current page, in wikitext format. The source page's name is inferred from the current page's name, but a page name can be specified as the first argument to override this behavior. The link order and labeling are defined by Module:Languages/config. This function is used by {{Languages}} and replaces {{Languages/div}}.

Parameters:

|1 =
(Optional) The name of the source page (the corresponding page in English). By default, the source page is inferred from the current page title, so this parameter is optional as long as the current page title is based on the English page's title.
|defaultsort =
(Optional) Set this parameter to no to omit the DEFAULTSORT that would be added by default. It is normally unnecessary to set this parameter.

This function generally does not check whether a translation exists; it merely links to all the pages that would contain translations in the wiki's languages. Outside of the content namespaces, for any language that has its own language namespace, this function does check whether there exists a page in the form "Namespace:XY:Page name" or "Namespace:Xy:Page name", because both spellings are possible.

MediaWiki:Common.css and MediaWiki:Mobile.css hide redlinks by default; clicking the "Other languages" link unhides them so that the user can quickly begin translating.

If the page title begins with a language pseudonamespace, such as "El" for Greek, a DEFAULTSORT omitting the pseudonamespace is appended to the return value of this method. Set |defaultsort = no to disable this behavior.

If a translation is missing in any language that has its own language namespace, this function automatically adds the current page to the corresponding tracking category. The current page's sort key in the category consists of the current page's language code and title.

See also