From 1fb0528f9e5ebd8459fcfde27c6981dde6d03512 Mon Sep 17 00:00:00 2001 From: Eva Date: Tue, 25 Apr 2023 12:54:34 +0200 Subject: [PATCH] fix: take parameter values into account when caching translations --- scripts/uosc_shared/lib/intl.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/uosc_shared/lib/intl.lua b/scripts/uosc_shared/lib/intl.lua index 457fbd6..0f51cec 100644 --- a/scripts/uosc_shared/lib/intl.lua +++ b/scripts/uosc_shared/lib/intl.lua @@ -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()