fix: take parameter values into account when caching translations

This commit is contained in:
Eva 2023-04-25 12:54:34 +02:00 committed by Tomas Klaen
parent 23abd31025
commit 1fb0528f9e

View File

@ -75,11 +75,13 @@ function add_directory(path)
end
---@param text string
function t(text, ...)
function t(text, a)
if not text then return '' end
if cache[text] then return cache[text] end
cache[text] = string.format(locale[text] or text, ...)
return cache[text]
local key = text
if a then key = key .. '|' .. a end
if cache[key] then return cache[key] end
cache[key] = string.format(locale[text] or text, a or '')
return cache[key]
end
reload()