Multilingual – Module with functions in context of languages, language codes, language names.
Functions for templates
For language code 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.
1 – language code
Result: empty, if invalid
fallback
Is another language suitable as replacement?
1 – language version specifier to be supported
2 – language specifier of a possible replacement
Result: string with replacement code, or empty
findCode
Retrieve code of language name in local (current project) language.
A code itself will be identified, too.
1 – language name in local (current project) language
Result: string with code, or empty
fix
Fix frequently mistaken language code.
1 – presumable language code
Result: string with correction, or empty
format
Format one or more languages.
1 – language list or single item
slang – language of the answer, if not native
* – native (default)
! – current project
any valid code
shift – capitalization
c – capitalize all
d – downcase everything
f – capitalize first item only
m – downcase every first word in item only
link=1 – link items
scream – category title in case of error
split – split pattern, if list expected; e.g. split=, – otherwise 1 is regarded as single item
separator – list separator, else split
start – prepend first list element, if any
Result: string with formatted language names, or empty
getArticle
Retrieve local article name about the language assigned to this code
nothing – if not retrieved
getBase
Retrieve base language from possibly combined ISO language code.
1 – language code
Result: code of base language, or empty if invalid query
getName
Which name is assigned to this language code?
1 – language code
2 – language of the answer
* – in that language itself (default)
! – in project language
Any ISO code.
Result: name of language, or empty if unknown
int
Translated system message
1 – message ID
lang – language code
$1, $2, … $9 – parameters
isLang
Could this be an ISO language code?
1 – language code
nothing – if not
isLangWiki
Could this be a Wiki language version?
1 – language code
nothing – if not
linkArticle
Internal link to local article about the language assigned to this code
code
different link text (optional)
nothing – if not retrieved
message
Show text in best match of user language like system message
en – English text version
de – German text version
… – any further text version
$1 – parameter value for replacement
$2 – parameter value for replacement
… – …
$9 – parameter value for replacement
sitelink
Make link at local or other site with optimal linktext translation using Wikidata
1 – item ID
Result: internal link (within WMF), or empty if no sitelinks at all
tabData
Try to retrieve translated keyword from commons:Data:****.tab tables and present in best current language
1 – page identification on Commons; no need to prefix with Data: or to append .tab
2 – keyword of text element in table
alt – (optional) fallback text if failure cannot be remedied (no table, no entry)
Tables for internationalisation are supposed to match following condition:
field: string, with keyword for text element
field: localized, with multilingual text fragments
userLang
Try to support user language by application.
1 – space separated list of available ISO 639 codes
Result:
If the current user language is not a list element, the first element is used.
If the current user language is a variant like en-US or en-GB and that is not mentioned explicitly in list, base language (hereen) will be tried.
If nothing matches and no list is provided, the project language (herede), at least en for English will be returned.
wikibase
Optimal translation of wikibase component
1 – entity ID
2 – (optional)1 or descriptions; (default)0 or labels
failsafe
Version management
The Failsafe interface is heading for version management of globally distributed Lua modules. It enables modules equipped with this interface to
ensure, that a library module required by a template or another module available as local copy does support certain functionality, or complain if not.
administrate global updating and linking of module codes via Wikidata.
The Failsafe interface is present both at template level and for direct Lua access.
The functions in detail are (not all supported yet completely by every library):
Parameter
Value
Result
current
nothing false
local version ID
»2025-03-05«
Minimal version
version ID required at least date in ISO format
It will be compared whether the current local implementation matches this version or later.
empty, if minimal version not achieved
2001-01-01 → »2025-03-05«
2099-01-01 →»«
wikidata
version ID of global upstream
version ID at Wikidata
local, if not found there
»2025-03-05«
item
ID of the Wikidata item
empty if not defined
Q47541920
~
Corresponding version ID locally and registered at Wikidata
empty, if up to date
version ID at Wikidata, if not equal
»«
@
Is the current (module) page linked correctly with Wikidata item?
empty, if linked to the item which is supposed
Iitem ID, if not
The return value is in template programming empty or under Lua false, otherwis a non-empty string as described.
All functions described above can be used by other modules:
locallucky,Multilingual=pcall(require,"Module:Multilingual")iftype(Multilingual)=="table"thenMultilingual=Multilingual()else-- failure; Multilingual is the error messagereturn"<span class='error'>"..Multilingual.."</span>"end