2020-06-03 18:40:05 -04:00
|
|
|
# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2018-07-31 19:53:54 -04:00
|
|
|
# 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:]
|
|
|
|
|
2023-11-16 08:27:06 -05:00
|
|
|
synthetic = polib.pofile("locale/synthetic.pot")
|
2023-11-14 12:27:42 -05:00
|
|
|
synthetic_ids = set([x.msgid for x in synthetic])
|
2018-07-31 19:53:54 -04:00
|
|
|
template = polib.pofile(template_filename)
|
2023-11-14 12:27:42 -05:00
|
|
|
all_ids = set([x.msgid for x in template]) - synthetic_ids
|
2018-07-31 19:53:54 -04:00
|
|
|
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])
|
|
|
|
|
2019-08-19 10:25:36 -04:00
|
|
|
missing = all_ids - po_ids
|
|
|
|
if missing:
|
2023-07-29 08:39:44 -04:00
|
|
|
print(
|
|
|
|
"Missing message id. Please run `make translate` and then `git commit locale/circuitpython.pot`"
|
|
|
|
)
|
2019-08-19 10:25:36 -04:00
|
|
|
print(missing)
|
2018-07-31 19:53:54 -04:00
|
|
|
sys.exit(-1)
|
|
|
|
else:
|
|
|
|
print("ok")
|