From ca25f63af14b20a88583a28984748432e213905f Mon Sep 17 00:00:00 2001 From: EtienneLescot Date: Sun, 27 Sep 2026 13:44:55 +0200 Subject: [PATCH] fix(i18n): only check calls to translators, not every name starting with t The key check matched \b(t[A-Z]?\w*)\( and so read tierOutputDims("source") as a translation call, failing i18n:check on the integration branch. A callee now counts when the file binds it to useScopedT, or when it is named like a translator handed in as a prop: t, or t plus a capital. Checked by mutation: unknown keys through ts, tCommon and t still fail; trimSomething("x") is ignored. --- scripts/i18n-check.mjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/i18n-check.mjs b/scripts/i18n-check.mjs index 024774a79..25b248554 100644 --- a/scripts/i18n-check.mjs +++ b/scripts/i18n-check.mjs @@ -225,8 +225,14 @@ for (const file of sourceFiles) { const bindings = [ ...source.matchAll(/\b(?:const|let|var)\s+(\w+)\s*=\s*useScopedT\(\s*"(\w+)"\s*\)/g), ].map((m) => ({ name: m[1], ns: m[2], at: m.index })); - for (const match of source.matchAll(/\b(t[A-Z]?\w*)\(\s*"([\w.-]+)"/g)) { + // A callee is a translator when the file binds it to useScopedT, or when it is named like + // one handed in as a prop or parameter: `t`, or `t` plus a capital (`tCommon`). Any other + // name starting with a t, like `tierOutputDims("source")`, is not a translation call. + const bound = new Set(bindings.map((b) => b.name)); + const isTranslator = (callee) => bound.has(callee) || /^t(?:[A-Z]\w*)?$/.test(callee); + for (const match of source.matchAll(/\b([A-Za-z_]\w*)\(\s*"([\w.-]+)"/g)) { const [, callee, key] = match; + if (!isTranslator(callee)) continue; checkedKeyCount++; const own = bindings.filter((b) => b.name === callee); const nearest = own.filter((b) => b.at < match.index).at(-1);