From 38e7aa213821e129e9f2e93dc47a495ab272dd23 Mon Sep 17 00:00:00 2001 From: Sang Han Date: Sat, 17 Jan 2026 23:07:46 -0800 Subject: [PATCH 1/2] fix: add missing tostring() call --- script/locale-loader.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/script/locale-loader.lua b/script/locale-loader.lua index 018da6806..10d76c53b 100644 --- a/script/locale-loader.lua +++ b/script/locale-loader.lua @@ -2,8 +2,9 @@ local function mergeKey(key, k) if not key then return k end - if k:sub(1, 1):match '%w' then - return key .. '.' .. k + k = tostring(k) + if k:sub(1, 1):match("%w") then + return key .. "." .. k else return key .. k end @@ -11,17 +12,17 @@ end local function proxy(results, key) return setmetatable({}, { - __index = function (_, k) + __index = function(_, k) return proxy(results, mergeKey(key, k)) end, - __newindex = function (_, k, v) + __newindex = function(_, k, v) results[mergeKey(key, k)] = v - end + end, }) end -return function (text, path, results) +return function(text, path, results) results = results or {} - assert(load(text, '@' .. path, "t", proxy(results)))() + assert(load(text, "@" .. path, "t", proxy(results)))() return results end From e9b52e69fcc6568e3940c939627aced641a1e254 Mon Sep 17 00:00:00 2001 From: Sang Han Date: Sat, 17 Jan 2026 23:22:21 -0800 Subject: [PATCH 2/2] add back to changelog --- changelog.md | 1 + script/locale-loader.lua | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/changelog.md b/changelog.md index d4ecb8039..c40a9a9ef 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ ## Unreleased +* `FIX` convert all keys to string before using ## 3.16.4 `2025-12-25` diff --git a/script/locale-loader.lua b/script/locale-loader.lua index 10d76c53b..c98529830 100644 --- a/script/locale-loader.lua +++ b/script/locale-loader.lua @@ -3,8 +3,8 @@ local function mergeKey(key, k) return k end k = tostring(k) - if k:sub(1, 1):match("%w") then - return key .. "." .. k + if k:sub(1, 1):match '%w' then + return key .. '.' .. k else return key .. k end @@ -12,17 +12,17 @@ end local function proxy(results, key) return setmetatable({}, { - __index = function(_, k) + __index = function (_, k) return proxy(results, mergeKey(key, k)) end, - __newindex = function(_, k, v) + __newindex = function (_, k, v) results[mergeKey(key, k)] = v - end, + end }) end -return function(text, path, results) +return function (text, path, results) results = results or {} - assert(load(text, "@" .. path, "t", proxy(results)))() + assert(load(text, '@' .. path, "t", proxy(results)))() return results end