diff --git a/l10n.py b/l10n.py index 5f6c5298..8fc499b5 100755 --- a/l10n.py +++ b/l10n.py @@ -83,7 +83,7 @@ class Translations: :param lang: The language to translate to, defaults to the preferred language """ - available = self.available() + available: set[str] = self.available() available.add(Translations.FALLBACK) if not lang: # Choose the default language @@ -331,33 +331,3 @@ class _Locale: # singletons Locale = _Locale() translations = Translations() - -# generate template strings file - like xgettext -# parsing is limited - only single ' or " delimited strings, and only one string per line -if __name__ == "__main__": - regexp = re.compile(r'''_\([ur]?(['"])(((? 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.")