Jump to content

Module:I18n/doc

විකිපීඩියා වෙතින්

I18n library for message storage in Lua datastores. The module is designed to enable message separation from modules & templates. It has support for handling language fallbacks. This module is a Lua port of wikia:dev:I18n-js and i18n modules that can be loaded by it are editable through wikia:dev:I18nEdit.

On Wikimedia projects, i18n messages are editable through Data:i18n/ subpages on Wikimedia Commons.

Documentation

Package items

i18n.getMsg(frame) (function)
Localized message getter by key.
Parameters:
frame Frame table. (table)
frame.args[1] ROOTPAGENAME of i18n submodule. (string)
frame.args[2] Message key. (string)
frame.args.lang Default language. (string; optional)
Error: 'missing arguments in i18n.getMsg' (string; line 271)
Returns: Localized message. (string)
i18n.loadMessages(...) (function)
I18n message datastore loader.
Parameter: ... ROOTPAGENAME/path for i18n submodules. (string)
Error: 'no source supplied to i18n.loadMessages' (string; line 322)
Returns: I18n datastore instance. (table)
i18n.getLang() (function)
Language code getter.
Returns: Language code. (string)
i18n.loadI18n(name, i18n_arg) (function)
Given an i18n table instantiates the values (deprecated).
Parameters:
name Name of module with i18n. (string)
i18n_arg Existing i18n table. (table)
i18n.loadI18nFrame(name, i18n_arg) (function)
Loads an i18n for a specific frame (deprecated).
Parameters:
name Name of module with i18n. (string)
i18n_arg Existing i18n table. (table)
i18n.main(frame) (function)
Wrapper for the module.
Parameter: frame Frame invocation object. (table)
Returns: Module output. (string)
_i18n.isWikitext(msg) (function)
Checks whether a message contains unprocessed wikitext. Used to optimise message getter by not preprocessing pure text.
Parameter: msg Message to check. (string)
Returns: Whether the message contains wikitext. (boolean)

Data

I18n datastore class.

Data:msg(opts, ...) (function)
Datastore message getter utility.
Parameters:
opts Message configuration or key. (string|table)
opts.key Message key. (string; optional)
opts.args Arguments for $n substitution. (table; optional)
opts.sources Source names to limit to. (table; optional)
opts.lang Temporary language. (table; optional)
... Arguments for $n substitution. (string; optional)
Error: 'missing arguments in Data:msg' (string; line 115)
Returns: Localised message or '<key>'. (string)
Data:parameter(key, args) (function)
Datastore template parameter getter utility.
Parameters:
key Parameter key in the datastore. (string)
args Arguments to find the parameter in. (table)
Error: 'missing arguments in Data:parameter' (string; line 176)
Returns: Parameter value or nil. (string|nil)
Data:fromSource(...) (function)
Datastore temporary source setter.
Parameter: ... Source name(s). (string)
Returns: Datastore instance. (Data)
Data:getLang() (function)
Datastore default language getter.
Returns: Default language. (string)
Data:useUserLang() (function)
Datastore language setter to wgUserLanguage.
Returns: Datastore instance. (Data)
Data:useContentLang() (function)
Datastore language setter to wgContentLanguage.
Returns: Datastore instance. (Data)
Data:useLang(code) (function)
Datastore language setter to specified language.
Parameter: code Language code. (string)
Returns: Datastore instance. (Data)
Data:inUserLang() (function)
Temporary datastore language setter to wgUserLanguage.
Returns: Datastore instance. (Data)
Data:inContentLang() (function)
Temporary datastore language setter to wgContentLanguage.
Returns: Datastore instance. (Data)
Data:inLang(code) (function)
Temporary datastore language setter to specified language.
Parameter: code Language code. (string)
Returns: Datastore instance. (Data)

See also

"https://si.wikipedia.org/w/index.php?title=Module:I18n/doc&oldid=740030" වෙතින් සම්ප්‍රවේශනය කෙරිණි