# VibeStack Weekly (https://vibestackweekly.com) | Localization placeholder checker (Godot-style CSV) # From https://vibestackweekly.com/ai-game-localization-tools/#placeholder-check # MIT License. Copyright (c) 2026 VibeStack Weekly. # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, # publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or # substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT # NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # Usage: python3 check_placeholders.py strings.csv [source_column] (exit code 1 when a row's placeholders don't match) import csv, re, sys from collections import Counter TOKEN = re.compile(r"%(?:\d+\$)?[-+ 0#]*\d*(?:\.\d+)?[sdif]|\{[A-Za-z0-9_]*\}|\[/?[a-z_]+(?:=[^\]]*)?\]|\\n") def tokens(s): return Counter(TOKEN.findall(s or "")) path, src = sys.argv[1], (sys.argv[2] if len(sys.argv) > 2 else "en") bad = 0 with open(path, encoding="utf-8", newline="") as f: rows = csv.reader(f); head = next(rows) langs = [c for c in head[1:] if c and not c.startswith(("_", "?"))] for row in rows: cells = dict(zip(head, row)) if not row or not cells.get(src): continue # skip blank or plural-continuation rows want = tokens(cells[src]) for lang in langs: if lang == src or not cells.get(lang): continue got = tokens(cells[lang]) if got != want: bad += 1 print(f"{row[0]} [{lang}]: expected {sorted(want.elements())}, got {sorted(got.elements())}") print(f"{bad} problem(s) found"); sys.exit(1 if bad else 0)