Luang is the fusion of Lua
and Lang
, it is a simple library that uses the flexibility of the metatables to access translations.
Look at examples/
to understand the usage.
-- lib
local Luang = require("Luang")
-- create Lang object (or "translator")
local tr = Luang()
-- load a dict table to the lang dict (merge into the internal dict)
-- dict: table with sub-tables and strings
tr:load(dict)
-- load a dict table to the lang dict for a specific locale
-- equivalent to tr:load({[locale] = dict})
-- dict: table with sub-tables and strings
-- locale: prefix
tr:loadLocale(locale, dict)
-- lang access property
tr.lang
-- access translation
-- args: table used to replace {keys} with values in the translation string (can be nil)
tr.lang.foo.bar(args)