diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2018-07-31 16:53:54 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2018-08-07 14:58:57 -0700 |
| commit | 933add6cd833bb6ba6682ad2b6eb478871415ff5 (patch) | |
| tree | 8cb5ee1feb0516c24ee270fcee5ed00d310aced8 /tools | |
| parent | 2029c4e87e3e71ada07c8be91fe6877edf4a606b (diff) | |
Support internationalisation.
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/build_adafruit_bins.sh | 77 | ||||
| -rw-r--r-- | tools/check_translations.py | 23 | ||||
| -rwxr-xr-x | tools/mpy-tool.py | 2 |
3 files changed, 61 insertions, 41 deletions
diff --git a/tools/build_adafruit_bins.sh b/tools/build_adafruit_bins.sh index 29ee35c6a..94c6a3646 100755 --- a/tools/build_adafruit_bins.sh +++ b/tools/build_adafruit_bins.sh @@ -16,22 +16,6 @@ else boards=$TRAVIS_BOARD fi -for board in $boards; do - if [ $board == "feather_huzzah" ]; then - make $PARALLEL -C ports/esp8266 BOARD=feather_huzzah - (( exit_status = exit_status || $? )) - elif [ $board == "feather52832" ]; then - make $PARALLEL -C ports/nrf BOARD=feather52832 - (( exit_status = exit_status || $? )) - elif [ $board == "pca10056" ]; then - make $PARALLEL -C ports/nrf BOARD=pca10056 SD=s140 - (( exit_status = exit_status || $? )) - else - make $PARALLEL -C ports/atmel-samd BOARD=$board - (( exit_status = exit_status || $? )) - fi -done - version=`git describe --tags --exact-match` if [ $? -ne 0 ]; then version=`date +%Y%m%d`-`git rev-parse --short HEAD` @@ -49,31 +33,44 @@ fi for board in $boards; do mkdir -p bin/$board/ extension=uf2 - if [ $board == "feather_huzzah" ]; then - cp ports/esp8266/build/firmware-combined.bin bin/$board/adafruit-circuitpython-$board-$version.bin - (( exit_status = exit_status || $? )) - extension=bin - elif [ $board == "feather52832" ]; then - cp ports/nrf/build-$board-s132/firmware.bin bin/$board/adafruit-circuitpython-$board-$version.bin - (( exit_status = exit_status || $? )) - extension=bin - elif [ $board == "pca10056" ]; then - cp ports/nrf/build-$board-s140/firmware.bin bin/$board/adafruit-circuitpython-$board-$version.bin - (( exit_status = exit_status || $? )) - extension=bin - else - cp ports/atmel-samd/build-$board/firmware.bin bin/$board/adafruit-circuitpython-$board-$version.bin + for language_file in $(ls locale/*.po); do + language=$(basename -s .po $language_file) + echo "Building $board for $language" + if [ $board == "feather_huzzah" ]; then + make $PARALLEL -C ports/esp8266 TRANSLATION=$language BOARD=feather_huzzah + (( exit_status = exit_status || $? )) + temp_filename=ports/esp8266/build/firmware-combined.bin + extension=bin + elif [ $board == "feather52832" ]; then + make $PARALLEL -C ports/nrf TRANSLATION=$language BOARD=feather52832 + (( exit_status = exit_status || $? )) + temp_filename=ports/nrf/build-$board-s132/firmware.bin + extension=bin + elif [ $board == "pca10056" ]; then + make $PARALLEL -C ports/nrf TRANSLATION=$language BOARD=pca10056 SD=s140 + (( exit_status = exit_status || $? )) + temp_filename=ports/nrf/build-$board-s140/firmware.bin + extension=bin + else + time make $PARALLEL -C ports/atmel-samd TRANSLATION=$language BOARD=$board + (( exit_status = exit_status || $? )) + cp ports/atmel-samd/build-$board/firmware.bin bin/$board/adafruit-circuitpython-$board-$language-$version.bin + (( exit_status = exit_status || $? )) + temp_filename=ports/atmel-samd/build-$board/firmware.uf2 + extension=uf2 + fi + final_filename=bin/$board/adafruit-circuitpython-$board-$language-$version.$extension + cp $temp_filename $final_filename (( exit_status = exit_status || $? )) - cp ports/atmel-samd/build-$board/firmware.uf2 bin/$board/adafruit-circuitpython-$board-$version.uf2 - (( exit_status = exit_status || $? )) - fi - # Only upload to Rosie if its a pull request. - if [ "$TRAVIS" == "true" ]; then - for rosie in $ROSIE_SETUPS; do - echo "Uploading to https://$rosie.ngrok.io/upload/$sha" - curl -F "file=@bin/$board/adafruit-circuitpython-$board-$version.$extension" https://$rosie.ngrok.io/upload/$sha - done - fi + # Only upload to Rosie if its a pull request. + if [ "$TRAVIS" == "true" ]; then + for rosie in $ROSIE_SETUPS; do + echo "Uploading to https://$rosie.ngrok.io/upload/$sha" + curl -F "file=@$final_filename" https://$rosie.ngrok.io/upload/$sha + done + fi + echo + done done exit $exit_status 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") diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index eeb760a5f..7deb76a8d 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -571,7 +571,7 @@ def main(): # set config values for qstrs, and get the existing base set of qstrs if args.qstr_header: - qcfgs, base_qstrs = qstrutil.parse_input_headers([args.qstr_header]) + qcfgs, base_qstrs, _ = qstrutil.parse_input_headers([args.qstr_header]) config.MICROPY_QSTR_BYTES_IN_LEN = int(qcfgs['BYTES_IN_LEN']) config.MICROPY_QSTR_BYTES_IN_HASH = int(qcfgs['BYTES_IN_HASH']) else: |
