From 5fe0f5567651a2ca433169259d475e592d782624 Mon Sep 17 00:00:00 2001 From: aussig Date: Sun, 11 Jan 2026 13:23:11 +0000 Subject: [PATCH] Adjust regex for finding `# LANG:` comments to cope with `#` characters earlier on the same line. Alpha sort localised strings in output. Support `# LANG: Ignore` to allow a string to be ignored and omitted from the output. EDCD/EDMarketConnector#2586 --- scripts/find_localised_strings.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/find_localised_strings.py b/scripts/find_localised_strings.py index 02f928e3..a72e0f07 100644 --- a/scripts/find_localised_strings.py +++ b/scripts/find_localised_strings.py @@ -60,7 +60,7 @@ COMMENT_OWN_LINE_RE is for a comment on its own line. The difference is necessary in order to tell if a 'above' LANG comment is for its own line (SAME_LINE), or meant to be for this following line (OWN_LINE). """ -COMMENT_SAME_LINE_RE = re.compile(r"^.*?(#.*)$") +COMMENT_SAME_LINE_RE = re.compile(r"^.*(#.*)$") COMMENT_OWN_LINE_RE = re.compile(r"^\s*?(#.*)$") @@ -245,6 +245,8 @@ def generate_lang_template(data: dict[pathlib.Path, list[ast.Call]]) -> str: entries: list[LangEntry] = [] for path, calls in data.items(): for c in calls: + if getattr(c, "comment") == "Ignore": + continue entries.append( LangEntry( [FileLocation.from_call(path, c)], @@ -259,7 +261,8 @@ def generate_lang_template(data: dict[pathlib.Path, list[ast.Call]]) -> str: """ print(f"Done Deduping entries {len(entries)=} {len(deduped)=}", file=sys.stderr) - for entry in deduped: + + for entry in sorted(deduped, key=lambda e: e.string.lower()): if len(entry.comments) != len(entry.locations): raise ValueError("Mismatch: 'comments' and 'locations' must have the same length.")