[init] handle the case in which translate() gets called with no dictionary.

This commit is contained in:
Lorenzo Cogotti 2022-08-17 12:14:32 +02:00
parent cc9d45cb44
commit a3488431b2
1 changed files with 2 additions and 1 deletions

View File

@ -90,8 +90,9 @@ end
--
-- @return localized and formatted string.
function moonspeak.translate(id, ...)
local msg = rawget(moonspeak.dict, id)
local dict = moonspeak.dict
local lang = moonspeak.lang
local msg = dict and dict[id] or nil
if msg ~= nil and msg[lang] then
-- Found localized string.