diff options
author | Jo-Philipp Wich <jo@mein.io> | 2018-10-18 10:54:12 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2018-11-05 11:01:45 +0100 |
commit | a04028037e8ba142737ff39ac5a2e78f07bc75c3 (patch) | |
tree | 3db82b96435687d8f84abf97dafbf9598d43604a /modules/luci-base | |
parent | 08255e266b590e43c2c9362206928ff7c8a9ab5c (diff) |
luci-base: introduce luci.i18n.dump()
Add a new luci.i18n.dump() function which returns all currently loaded
translation strings as Lua table.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base')
-rw-r--r-- | modules/luci-base/luasrc/i18n.lua | 6 | ||||
-rw-r--r-- | modules/luci-base/luasrc/i18n.luadoc | 16 |
2 files changed, 20 insertions, 2 deletions
diff --git a/modules/luci-base/luasrc/i18n.lua b/modules/luci-base/luasrc/i18n.lua index 968c387f1..42de832f7 100644 --- a/modules/luci-base/luasrc/i18n.lua +++ b/modules/luci-base/luasrc/i18n.lua @@ -69,3 +69,9 @@ end function stringf(key, ...) return tostring(translate(key)):format(...) end + +function dump() + local rv = {} + tparser.get_translations(function(k, v) rv[k] = v end) + return rv +end diff --git a/modules/luci-base/luasrc/i18n.luadoc b/modules/luci-base/luasrc/i18n.luadoc index 13f10a107..df6e38e5d 100644 --- a/modules/luci-base/luasrc/i18n.luadoc +++ b/modules/luci-base/luasrc/i18n.luadoc @@ -6,7 +6,6 @@ module "luci.i18n" ---[[ Clear the translation table. - @class function @name clear ]] @@ -26,6 +25,7 @@ Load a translation and copy its data into the translation table. Load a translation file using the default translation language. Alternatively load the translation of the fallback language. + @class function @name loadc @param file Language file @@ -62,9 +62,10 @@ Return the translated value for a specific translation key and use it as sprintf ---[[ 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> + @class function @name string @param key Default translation text @@ -75,7 +76,9 @@ This is the same as calling <code>tostring(translate(...))</code> 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> + @class function @name stringf @param key Default translation text @@ -83,3 +86,12 @@ This is the same as calling <code>tostring(translatef(...))</code> @return Translated and formatted string ]] +---[[ +Return all currently loaded translation strings as a key-value table. The key is the +hexadecimal representation of the translation key while the value is the translated +text content. + +@class function +@name dump +@return Key-value translation string table. +]] |