Scripts: Add cleanup stale translations
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -90,17 +91,30 @@ def build_translations() -> None:
|
|||||||
check=True)
|
check=True)
|
||||||
|
|
||||||
|
|
||||||
|
def cleanup_translations() -> None:
|
||||||
|
for po_file in TRANS_DIR.glob('*.po'):
|
||||||
|
subprocess.run(['msgattrib',
|
||||||
|
'--output-file',
|
||||||
|
str(po_file),
|
||||||
|
'--no-obsolete',
|
||||||
|
str(po_file)],
|
||||||
|
cwd=REPO_DIR,
|
||||||
|
check=True)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser(description='Update Translations')
|
||||||
|
parser.add_argument('command', choices=['update', 'build', 'cleanup'])
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
build = False
|
if args.command == 'cleanup':
|
||||||
if len(sys.argv) > 1:
|
cleanup_translations()
|
||||||
cmd = sys.argv[1]
|
|
||||||
if cmd == 'build':
|
|
||||||
build = True
|
|
||||||
else:
|
|
||||||
exit('Unknown commands found: %s' % sys.argv)
|
|
||||||
|
|
||||||
update_translation_template()
|
elif args.command == 'update':
|
||||||
update_translation_files()
|
update_translation_template()
|
||||||
if build:
|
update_translation_files()
|
||||||
|
|
||||||
|
elif args.command == 'build':
|
||||||
|
update_translation_template()
|
||||||
|
update_translation_files()
|
||||||
build_translations()
|
build_translations()
|
||||||
|
|||||||
Reference in New Issue
Block a user