Module: lib-tde.i18n
This module handles translation inside of TDE
You can use the default translations of TDE inside of our plugin.
Alternatively you can add more translations into tde, which is useful if your translations don't exist yet
-- i18n is exposed to the plugin authors without needing to re-declare it -- They can already use default translations i18n.translate("Calculator") -- They can also add custom translations to the current language if i18n.system_language() == "nl_be" then i18n.custom_translations({ hello = "hallo", day = "dag", }) else if i18n.system_language() == "fr"journée i18n.custom_translations({ hello = "bonjour", day = "journée", }) end -- If the locale is dutch it becomes -> dag -- If the locale is french it becomes -> journée -- If it is any other language it becomes -> day (default) i18n.translate("day")
Info:
- Copyright: 2020 Tom Meyers
- Author: Tom Meyers
Static module functions
lib-tde.i18n.init (default) | Used to initialize i18n, (detect system language and load in translations) | |
lib-tde.i18n.translate (str) | Used to translate the line into the user language | |
lib-tde.i18n.custom_translations (tbl) | Add custom translations into the translation lookup table | |
lib-tde.i18n.system_language () | Get the active system language | |
lib-tde.i18n.set_system_language (lang) | Change the system language to a new value (reloading the translation table, all old custom translations become lost) |
Static module functions
- lib-tde.i18n.init (default)
-
Used to initialize i18n, (detect system language and load in translations)
Parameters:
- default string The default language to use in case no translations exist for the system language
Usage:
-- Initialize i18n if the system language is not found default to English i18n.init("en")
- lib-tde.i18n.translate (str)
-
Used to translate the line into the user language
Parameters:
- str string The string to translate
Usage:
-- The word hello gets translated to the native language of the user i18n.translate("hello") -- becomes hallo if the system language is dutch
- lib-tde.i18n.custom_translations (tbl)
-
Add custom translations into the translation lookup table
Parameters:
- tbl table The table holding key value pairs containing the new translations
Usage:
-- add the translation hello -> hi i18n.custom_translations({hello="hi"}) i18n.translate("hello") -- returns hi
- lib-tde.i18n.system_language ()
-
Get the active system language
Usage:
-- Returns the current active translation language i18n.system_language() -- returns the system language
- lib-tde.i18n.set_system_language (lang)
-
Change the system language to a new value (reloading the translation table, all old custom translations become lost)
Parameters:
- lang string The new language to use
Usage:
-- Update the language to English i18n.set_system_language("en")