46bfbad1bb
This returns the localization of the running CircuitPython, such as en_US, fr, etc. Additional changes are needed in build infrastructure since the string "en_US" should not appear to be translated in weblate, ever; instead the value comes from the translation metadata. Closes: #8602
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
# 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:]
|
|
|
|
synthetic = polib.pofile("locale/synthetic.po")
|
|
synthetic_ids = set([x.msgid for x in synthetic])
|
|
template = polib.pofile(template_filename)
|
|
all_ids = set([x.msgid for x in template]) - synthetic_ids
|
|
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])
|
|
|
|
missing = all_ids - po_ids
|
|
if missing:
|
|
print(
|
|
"Missing message id. Please run `make translate` and then `git commit locale/circuitpython.pot`"
|
|
)
|
|
print(missing)
|
|
sys.exit(-1)
|
|
else:
|
|
print("ok")
|