Module:Common/doc
This is the documentation page for Module:Common
Module:Common
Shared stateless helper functions, which can be loaded in other Lua modules via:
local common = require("Module:Common")
Usage
This module also exposes a few permanent utility entry points.
Get URL-safe version of a given string
MessageBundle keys are built from a slugified (URL-safe) version of a string. Use this to check the exact slug a given input will produce.
If no value is specified, it defaults to the current page's title:
{{#invoke:Common|checkSlug}}
A specific string can also be provided instead:
{{#invoke:Common|checkSlug|Terrarium of Muad'Dib}}
Get an auto-localised string from a MessageBundle
Retrieves a string for a given key from a specified MessageBundle. It auto-switches to the language that the viewer's page is currently on, and falls back to the English source if no translation exists for the current language.
{{#invoke:Common|localise|Vehicles|sandbike-name}}
Optionally, set link=yes to wrap the result as a stable link to the English page name, e.g. [[Wildlife of Arrakis|Fauna von Arrakis]]:
{{#invoke:Common|localise|DLC|wildlife-of-arrakis-name|link=yes}}
Parameters
checkSlug
- 1 (optional)
- string
- The string to generate a slug for.
- If omitted, defaults to the current page's title.
localise
- 1
- string
- The name of the MessageBundle to look up (without the "MessageBundle:" prefix).
- 2
- string
- The key to retrieve from the MessageBundle.
- link (optional)
- boolean
- If true, wraps the result as
[[English|Translation]]instead of just plain text. - Defaults to false.