Global Lua Modules/I18n

I18n-lua is a library for message storage as Lua datastores. It enables message separation from modules and templates. It has limited support for handling language fallbacks. This module is a Lua port of I18n-js.

TODO: Extended fallback support using Module:FallbackList.

I18n datastore
To use the module, you need to set up your messages in the appropriate place and correct format. The message loader will expect your messages to be in a page such as, where PAGENAME should be the name of your module. The format of your messages should be as follows:

Messages can have arguments for substitution in templates/modules - these should be specified in the form  where n is a integer greater than 0, e.g,.

Fetching the messages
Once you've set up the messages, there are two ways to fetch them:

1. Import the module into a Lua module and create a datastore instance using the   method:

2. Fetch messages directly within your template:

Use in templates

 * This fetches the appropriate language code to describe user preference.
 * Allows validation of a template's language code through  parameter.
 * Usage :
 * Usage :


 * This fetches individual, localized messages from a datastore by key.
 * Allows returning messages in a specific language code through  parameter.
 * Allows message substitution by passing through extra numbered parameters.
 * Usage :
 * Usage :

Message usage in Lua
When we have created our  datastore instance, it will control access to your individual messages as well as the language it tries to translate them into. It defines the following 4 methods:
 * Set the default language to, e.g..
 * By default, the language will be the value of.
 * Set the default language to the value of.
 * Set the default language to the value of . Scribunto only registers wgUserLanguage in the   invocation context, so it must be passed as an argument.
 * Returns localised messages from the datastore corresponding to the  string.
 * Allows optional substitution of  parameters, using extra argument strings or a table of extra arguments.
 * Set the default language to the value of . Scribunto only registers wgUserLanguage in the   invocation context, so it must be passed as an argument.
 * Returns localised messages from the datastore corresponding to the  string.
 * Allows optional substitution of  parameters, using extra argument strings or a table of extra arguments.
 * Allows optional substitution of  parameters, using extra argument strings or a table of extra arguments.

Changelog

 * June 10, 2018‎
 * User:KockaAdmiralac: JSON-centric prototype and template testing.


 * June 12, 2018
 * User:Speedit: Port of I18n-js functions and Lua datastore support.


 * June 13, 2018
 * User:Speedit: Code cleanup, testing and


 * June 16, 2018
 * User:KockaAdmiralac, User:Speedit: Testing and tweaks
 * Failed testing of JSON support and caching.
 * Subpage  detection fix.