Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

i18n_coverage: fails on a key defined twice in a table (merges of two branches added 'Round' with two meanings and 'Merge' twice in batch 0.11.15)

islandmed1e42fd8a1539
diff --git a/tools/i18n/coverage.py b/tools/i18n/coverage.py
index d333efba..e6f760c3 100644
--- a/tools/i18n/coverage.py
+++ b/tools/i18n/coverage.py
@@ -485,14 +485,20 @@ def visible(s):
def load_table(path):
toks = tokens(path.read_text(encoding="utf-8"))
- table = {}
+ table, dups = {}, DUPLICATES.setdefault(path.name, [])
for i in range(len(toks) - 4):
if toks[i][1] == "{" and toks[i + 1][0] == "str" and toks[i + 2][1] == "," and toks[i + 3][0] == "str" \
and toks[i + 4][1] == "}":
- table[toks[i + 1][1].replace(ICON, "")] = toks[i + 3][1]
+ key = toks[i + 1][1].replace(ICON, "")
+ if key in table: # two branches added the same key; with different words, only one could ever show
+ dups.append((key, toks[i + 1][2]))
+ table[key] = toks[i + 3][1]
return table
+DUPLICATES = {} # table file -> [(key, line)] (load_table)
+
+
def translates(table, text):
"""tr()'s rule (I18n.cpp compose/translateCore): is there a translation of the label's words?"""
t = visible(text)
@@ -593,7 +599,11 @@ def main():
print(f" {s.replace(ICON, '<icon>')!r} {min(strings[s])}")
if stale:
print(f"keep_english.txt lines no string uses any more: {stale}")
- if args.check and (any(missing.values()) or stale):
+ dups = [f"{f}:{line} {k!r}" for f, d in DUPLICATES.items() for k, line in d]
+ if dups:
+ print("keys defined twice in a table (keep one; a different meaning needs a different English label):")
+ print(*(" " + d for d in dups), sep="\n")
+ if args.check and (any(missing.values()) or stale or dups):
print("i18n_coverage: add the missing strings to the tables (or keep_english.txt for names and units)")
return 1
return 0