From eae70af2b291c816298fe4796337883524d2b3e7 Mon Sep 17 00:00:00 2001 From: pepaskopec-blip Date: Tue, 6 Oct 2026 15:10:31 +0200 Subject: [PATCH] Include mathematics translations when extracting app content. Co-authored-by: Cursor --- scripts/extract-android-content.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/extract-android-content.py b/scripts/extract-android-content.py index 74d17ec..422e339 100644 --- a/scripts/extract-android-content.py +++ b/scripts/extract-android-content.py @@ -727,6 +727,20 @@ def parse_changelog(path: Path) -> list[dict]: return [e for e in entries if e["cs"] or e["en"]] +def expand_local_includes(src: str, directory: Path, seen: set[Path] | None = None) -> str: + """Inline #include "file" so keys that live in a fragment are extracted.""" + seen = set() if seen is None else seen + + def repl(match: re.Match) -> str: + path = (directory / match.group(1)).resolve() + if not path.is_file() or path in seen: + return match.group(0) + seen.add(path) + return expand_local_includes(path.read_text(encoding="utf-8"), path.parent, seen) + + return re.sub(r'^\s*#include\s+"([^"]+)"', repl, src, flags=re.M) + + def parse_i18n(src: str) -> dict: arrays = find_arrays(src) out = {} @@ -765,7 +779,7 @@ def main() -> int: text = strip_comments(path.read_text(encoding="utf-8")) arrays.update(find_arrays(text)) if path.name == "i18n.c": - i18n = parse_i18n(text) + i18n = parse_i18n(strip_comments(expand_local_includes(text, path.parent))) def A(name): if name not in arrays: