-function translate(key, def)
- 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 def
+function translate(key)
+ return tparser.translate(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(...)
+end
+
+--- Return the translated value for a specific translation key
+-- and ensure that the returned value is a Lua string value.
+-- This is the same as calling <code>tostring(translate(...))</code>
+-- @param key Default translation text
+-- @return Translated string
+function string(key)
+ return tostring(translate(key))