From 013e81b3c0cce15f00b9ae305641e4acbe7efcee Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 5 Dec 2020 13:13:04 +0100 Subject: [PATCH] Better sort in translation files, remove unwanted headers --- squirrelbattle/translations.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/squirrelbattle/translations.py b/squirrelbattle/translations.py index 5ce8986..d5ac3e2 100644 --- a/squirrelbattle/translations.py +++ b/squirrelbattle/translations.py @@ -3,6 +3,7 @@ import gettext as gt import os +import re import subprocess from pathlib import Path from typing import Any, List @@ -68,9 +69,14 @@ class Translator: "--copyright-holder=ÿnérant, eichhornchen, " "nicomarg, charlse", "--msgid-bugs-address=squirrel-battle@crans.org", + "--sort-by-file", "-o", file_name] if file_name.is_file(): args.append("--join-existing") + with open(file_name, "r") as f: + content = f.read() + with open(file_name, "w") as f: + f.write(re.sub("#:.*\n", "", content)) print(f"Make {language} messages...") subprocess.Popen(args, stdin=find.stdout).wait()