The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
fix(locales): the check prints on a Windows console, and counts the lines still in English
Jareer97378369941d
diff --git a/scripts/locales.py b/scripts/locales.pyindex 25459b3b..96fc6472 100755--- a/scripts/locales.py+++ b/scripts/locales.py@@ -5,6 +5,10 @@# source, and drop lines no source asks forscripts/locales.py --check # report what each locale lacks; exit 1 on# anything out of step+ scripts/locales.py --check --same+ # also list each line still in English+ scripts/locales.py --check --strict+ # ... and exit 1 on any of themA locale is a JSON file of keys to words: `"export.tenBitColour": "10-bitcolour"`. A key is dotted lowerCamelCase - the area of the interface the@@ -30,6 +34,17 @@ import pathlibimport reimport sys+# A Windows console prints in its code page - cp1252, most often - which+# has no Bengali, no Persian and no CJK, and the first locale name printed+# was an UnicodeEncodeError. The words are written as UTF-8 wherever this+# runs; a stream that cannot be reconfigured (one replaced by a test+# harness) is left as it is.+for _stream in (sys.stdout, sys.stderr):+ try:+ _stream.reconfigure(encoding="utf-8")+ except (AttributeError, ValueError):+ pass+ROOT = pathlib.Path(__file__).resolve().parent.parentCRATE = ROOT / "src" / "crates" / "concat"LOCALES = CRATE / "locales"@@ -44,6 +59,34 @@ PRESET = re.compile(r'look\(\s*"([^"]+)",\s*' + LITERAL)KEY = re.compile(r"^[a-z][A-Za-z0-9]*(\.[a-z][A-Za-z0-9]*)+$")+# Lines that read the same in every language and are not a translation+# someone forgot: the app's name, units, and the names of formats and+# things. `effects.*.name` is a look's name, which is a name like any+# other: "VHS" and "Cyberpunk" are what they are called everywhere.+SAME_KEYS = {+ "settings.concat",+ "controls.hertz",+ "controls.kelvin",+ "export.cbr",+ "export.vbr",+ "studio.lut",+}+SAME_PATTERNS = [re.compile(r"^effects\.[A-Za-z0-9]+\.name$")]+# A value made of nothing but places, numbers, units and acronyms is the+# same in every language too: "{0} Hz", "LUT", "4K".+UNITS = {"Hz", "kHz", "K", "dB", "px", "fps", "ms", "s", "x", "%"}+ACRONYM = re.compile(r"^[A-Z0-9][A-Z0-9.:/+-]*$")+++def same_is_fine(key: str, english: str) -> bool:+ """Whether a line identical to the English is meant to be."""+ if key in SAME_KEYS or any(pattern.match(key) for pattern in SAME_PATTERNS):+ return True+ words = re.sub(r"\{\d+\}", " ", english).split()+ return all(word in UNITS or ACRONYM.match(word) or not re.search(r"[A-Za-z]", word)+ for word in words)++def unescape(text: str) -> str:return text.replace('\\"', '"').replace("\\\\", "\\")@@ -137,8 +180,13 @@ def inventory() -> tuple[dict[str, str], list[str]]:return wanted, problems-def check(wanted: dict[str, str]) -> int:+def check(wanted: dict[str, str], list_same: bool = False, strict: bool = False) -> int:+ """Reports each locale's missing, stale and untranslated lines. Stale+ fails; a line still in English is counted, listed with `list_same`, and+ fails only with `strict` - there is a backlog of them, and it is to be+ seen before it is to be enforced."""failed = 0+ untranslated = 0for path in sorted(LOCALES.glob("*.json")):if path.name == "en.json":continue@@ -146,14 +194,27 @@ def check(wanted: dict[str, str]) -> int:strings = {k: v for k, v in data.items() if k != "_"}stale = sorted(set(strings) - set(wanted))missing = sorted(set(wanted) - set(strings))+ same = sorted(key for key, value in strings.items()+ if key in wanted and value == wanted[key]+ and not same_is_fine(key, wanted[key]))+ untranslated += len(same)name = data.get("_", {}).get("name", "")print(f"{path.stem:8s} {name:20s} {len(strings):4d} lines, "- f"{len(missing):3d} missing, {len(stale):3d} stale")+ f"{len(missing):3d} missing, {len(stale):3d} stale, "+ f"{len(same):3d} still English")for key in stale:print(f" stale: {key}")failed = 1for key in missing:print(f" missing: {key} ({wanted[key]!r})")+ if list_same or strict:+ for key in same:+ print(f" english: {key} ({wanted[key]!r})")+ if untranslated:+ print(f"warning: {untranslated} lines are the English word for word; "+ "--same lists them, --strict fails on them")+ if strict:+ failed = 1return failed@@ -173,7 +234,7 @@ def main() -> int:for key in sorted(k for k in set(wanted) & set(listed) if wanted[k] != listed[k]):print(f" changed: {key}")return 1- return 1 if problems else check(wanted)+ return 1 if problems else check(wanted, "--same" in sys.argv, "--strict" in sys.argv)write(LOCALES / "en.json", {"_": {"name": "English"}, **wanted})print(f"{len(wanted)} strings in {LOCALES / 'en.json'}")# A line for a string the interface no longer has is dropped: the