Module:Titlelib/doc

From Meta, a Wikimedia project coordination wiki

This is the documentation page for Module:Titlelib

Lua library for managing title strings.

isInterwiki[edit]

isInterwiki(String prefix, bool onlyInterlang = false): bool

Checks wether prefix is a valid interwiki prefix. I.e. wether the prefix is registered in mw.site.interwikiMap()

If onlyInterlang is true, it will only check for language prefixes ('en', 'pt'…), excluding website prefixes ('commons', 'wikiquote'…).

Returns true if prefix is a registered interwiki prefix, false else.

isInterlangPrefix[edit]

isInterlangPrefix(String prefix): bool

Checks wether prefix is a valid interlanguage prefix. I.e. wether the prefix is registered in mw.site.interwikiMap() and is known by mw.language.isKnownLanguageTag().

Equivalent to isInterwiki(prefix, true).

Returns true if prefix is a registered interlanguage prefix, false else.

isNamespace[edit]

isNamespace(String prefix): bool

Checks wether the prefix is a valid namespace prefix on Meta. I.e. wether the prefix is registered in mw.site.namespaces

Returns true if prefix is a registered interwiki prefix, false else.

langToWiki[edit]

langToWiki(String lang): String|bool

Gives a valid interwiki prefix for the requested language code.

Most interwiki prefixes are actually language codes, but some language code match with another interwiki. E.g. 'pt-br' language code matches with 'pt' interwiki prefix.

Returns the interwiki prefix related to the given language if possible, or false if none is known.

splitPrefixedTitle[edit]

splitPrefixedTitle(String title): String, String

Split title into two parts: interwiki prefixes and page title.

Returns 2 strings:

  • first one is all prefixes which are recognized as interwikis, joined with colon
  • second one is the rest of the given string

myLangLink[edit]

myLangLink(String pageLink): String

Prefixes page name with Special:MyLanguage.

Parameter[edit]

  • pageLink: Page name, eventually prefixed with interwiki prefixes and namespace.

Return[edit]

Returns name of page which links to given page link in user language.