diff --git a/builtin/intllib/init.lua b/builtin/intllib/init.lua index a6260c14e..45a3fe7ed 100644 --- a/builtin/intllib/init.lua +++ b/builtin/intllib/init.lua @@ -158,7 +158,7 @@ function intllib.make_gettext_pair(modname) if gettext_getters[modname] then return unpack(gettext_getters[modname]) end - local modpath = core.get_modpath(modname) and core.get_modpath(modname) + local modpath = core.get_modpath(modname) local localedir = modpath and modpath.."/locale" local catalogs = localedir and gettext.load_catalogs(localedir) or {} local getter = Getter(modname) @@ -192,7 +192,7 @@ function intllib.get_strings(modname, langcode) modname = modname or core.get_current_modname() local msgstr = intllib.strings[modname] if not msgstr then - local modpath = core.get_modpath(modname) and core.get_modpath(modname) + local modpath = core.get_modpath(modname) msgstr = { } if modpath then for _, l in ipairs(get_locales(langcode)) do @@ -207,3 +207,17 @@ function intllib.get_strings(modname, langcode) end return msgstr end + + +function core.get_translator_auto(langs) + if type(langs) == "table" then + for _, l in ipairs(langs) do + if LANG == l then + -- Surrounded in brackets so there's only one return value + return (intllib.make_gettext_pair()) + end + end + end + + return core.get_translator(core.get_current_modname()) +end