+ load(file, default, force)
+ if context.parent then load(file, context.parent, force) end
+ return load(file, context.lang, force)
+end
+
+--- Set the context default translation language.
+-- @param lang Two-letter language code
+function setlanguage(lang)
+ context.lang = lang:gsub("_", "-")
+ context.parent = (context.lang:match("^([a-z][a-z])_"))
+end
+
+--- Return the translated value for a specific translation key.
+-- @param key Default translation text
+-- @return Translated string
+function translate(key)
+ return (table[context.lang] and table[context.lang][key])
+ or (table[context.parent] and table[context.parent][key])
+ or (table[default] and table[default][key])
+ or key
+end
+
+--- Return the translated value for a specific translation key and use it as sprintf pattern.
+-- @param key Default translation text
+-- @param ... Format parameters
+-- @return Translated and formatted string
+function translatef(key, ...)
+ return tostring(translate(key)):format(...)