summaryrefslogtreecommitdiffhomepage
path: root/libs/web/luasrc/i18n.lua
diff options
context:
space:
mode:
Diffstat (limited to 'libs/web/luasrc/i18n.lua')
-rw-r--r--libs/web/luasrc/i18n.lua28
1 files changed, 12 insertions, 16 deletions
diff --git a/libs/web/luasrc/i18n.lua b/libs/web/luasrc/i18n.lua
index 9a11a9dc8..816d90310 100644
--- a/libs/web/luasrc/i18n.lua
+++ b/libs/web/luasrc/i18n.lua
@@ -93,42 +93,38 @@ function setlanguage(lang)
end
--- Return the translated value for a specific translation key.
--- @param key Translation key
--- @param def Default translation
+-- @param key Default translation text
-- @return Translated string
-function translate(key, def)
+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 def
+ or key
end
--- Return the translated value for a specific translation key and use it as sprintf pattern.
--- @param key Translation key
--- @param default Default translation
+-- @param key Default translation text
-- @param ... Format parameters
-- @return Translated and formatted string
-function translatef(key, default, ...)
- return tostring(translate(key, default)):format(...)
+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 Translation key
--- @param default Default translation
+-- @param key Default translation text
-- @return Translated string
-function string(key, default)
- return tostring(translate(key, default))
+function string(key)
+ return tostring(translate(key))
end
--- Return the translated value for a specific translation key and use it as sprintf pattern.
-- Ensure that the returned value is a Lua string value.
-- This is the same as calling <code>tostring(translatef(...))</code>
--- @param key Translation key
--- @param default Default translation
+-- @param key Default translation text
-- @param ... Format parameters
-- @return Translated and formatted string
-function stringf(key, default, ...)
- return tostring(translate(key, default)):format(...)
+function stringf(key, ...)
+ return tostring(translate(key)):format(...)
end