Module:Multilingual/doc explained

Multilingual – Module with functions in context of languages, language codes, language names.

Functions for templates

All functions expect one unnamed parameter 1 with the key information, and sometimes more optionals. Whitespace ahead and after any content is ignored. Upcasing of language code segments like in en-US does not matter; results are downcased.

The return value is an empty string (“nothing”), if the parameter value does not fulfil the expectations. If there is a result or the query condition is true, at least one visible character will be returned. The result does not begin or end with a space.

fair
  • Format language code according to RFC 5646 and check validity
    findCode
  • Retrieve code of language name in local (current project) language.
  • A code itself will be identified, too.
    format
  • Format one or more languages.
    getBase
  • Retrieve base language from possibly combined ISO language code.
    getName
  • Which name is assigned to this language code?
    isLang
  • Could this be an ISO language code?
    isLangWiki
  • Could this be a Wiki language version?
    kannDeutsch
  • Might someone with this language code understand German?
    userLang
  • Try to support user language by application.
    failsafe
  • Version ID: {{#invoke:Multilingual|failsafe}}
  • optional parameter 1 – required version
  • result: empty, if requirement not met

    Examples (test page)

    A test page illustrates practical use.

    Functions for Lua modules (API)

    All functions described above can be used by other modules:local lucky, Multilingual = pcall(require, "Module:Multilingual")if type(Multilingual)

    "table" then Multilingual = Multilingual.Multilingualelse -- failure; Multilingual is the error message return "

    " .. Multilingual .. ""endSubsequently there are available:
    Multilingual.fair(ask)
    Multilingual.findCode(ask)
  • Multilingual.format(apply, alien, alter, active, alert, frame, assembly, adjacent)
  • Multilingual.getBase(ask)
  • Multilingual.getLang(ask)
  • Split language code into components
  • Returns: table
  • .base – Basic language (2–3 lowercase letters)
  • .region – Country (2 uppercase letters)
  • .script – Scripting (4 letters, capitalized)
  • .year – year (4 digits)
  • .extension – Extension (1 lowercase letter)
  • .other – More
  • .legaltrue if valid
  • .n – Number of components
    Multilingual.getName(ask, alien)
    Multilingual.isLang(ask)
  • Multilingual.isLangWiki(ask)
  • Multilingual.kannDeutsch(ask)
  • Multilingual.userLang(accept, frame)
  • Multilingual.failsafe(atleast)

    If succeeding, the Multilingual.get* return a string, the Multilingual.is* true; on failure false.

    Usage

    General library; no limitations.

    Dependencies