From 933add6cd833bb6ba6682ad2b6eb478871415ff5 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 31 Jul 2018 16:53:54 -0700 Subject: Support internationalisation. --- tools/check_translations.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tools/check_translations.py (limited to 'tools/check_translations.py') diff --git a/tools/check_translations.py b/tools/check_translations.py new file mode 100644 index 000000000..4bea040bf --- /dev/null +++ b/tools/check_translations.py @@ -0,0 +1,23 @@ +# Validate that all entries in the .pot are in every .po. Only the .pot is updated so we can detect +# if a translation was added to the source but isn't in a .po. This ensures translators can grab +# complete files to work on. + +import sys +import polib + + +template_filename = sys.argv[1] +po_filenames = sys.argv[2:] + +template = polib.pofile(template_filename) +all_ids = set([x.msgid for x in template]) +for po_filename in po_filenames: + print("Checking", po_filename) + po_file = polib.pofile(po_filename) + po_ids = set([x.msgid for x in po_file]) + + if all_ids - po_ids: + print("Missing message id. Please run `make translate`") + sys.exit(-1) + else: + print("ok") -- cgit v1.2.3