From 933add6cd833bb6ba6682ad2b6eb478871415ff5 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 31 Jul 2018 16:53:54 -0700 Subject: [PATCH] Support internationalisation. --- .travis.yml | 18 +- Makefile | 19 +- locale/circuitpython.pot | 673 ++++++++++++++++++ locale/en_US.po | 673 ++++++++++++++++++ locale/es.po | 673 ++++++++++++++++++ main.c | 49 +- mpy-cross/Makefile | 1 + ports/atmel-samd/Makefile | 13 +- .../atmel-samd/common-hal/analogio/AnalogIn.c | 3 +- .../common-hal/analogio/AnalogOut.c | 3 +- .../atmel-samd/common-hal/audiobusio/I2SOut.c | 23 +- .../atmel-samd/common-hal/audiobusio/PDMIn.c | 15 +- .../atmel-samd/common-hal/audioio/AudioOut.c | 19 +- ports/atmel-samd/common-hal/busio/I2C.c | 10 +- ports/atmel-samd/common-hal/busio/UART.c | 15 +- .../common-hal/digitalio/DigitalInOut.c | 3 +- .../common-hal/microcontroller/__init__.c | 3 +- ports/atmel-samd/common-hal/pulseio/PWMOut.c | 11 +- ports/atmel-samd/common-hal/pulseio/PulseIn.c | 11 +- .../atmel-samd/common-hal/pulseio/PulseOut.c | 5 +- .../common-hal/rotaryio/IncrementalEncoder.c | 5 +- ports/atmel-samd/common-hal/rtc/RTC.c | 3 +- .../atmel-samd/common-hal/storage/__init__.c | 3 +- ports/atmel-samd/common-hal/touchio/TouchIn.c | 5 +- ports/atmel-samd/common-hal/usb_hid/Device.c | 5 +- ports/esp8266/Makefile | 1 + ports/unix/Makefile | 1 + py/makeqstrdata.py | 64 +- py/makeqstrdefs.py | 10 +- py/makeversionhdr.py | 1 - py/mkrules.mk | 8 +- py/modbuiltins.c | 16 +- py/modstruct.c | 9 +- py/py.mk | 23 +- py/qstr.c | 2 + py/qstr.h | 6 +- shared-bindings/_stage/Layer.c | 7 +- shared-bindings/_stage/Text.c | 7 +- shared-bindings/analogio/AnalogOut.c | 3 +- shared-bindings/audiobusio/I2SOut.c | 3 +- shared-bindings/audiobusio/PDMIn.c | 15 +- shared-bindings/audioio/AudioOut.c | 3 +- shared-bindings/audioio/RawSample.c | 5 +- shared-bindings/audioio/WaveFile.c | 5 +- shared-bindings/bitbangio/I2C.c | 5 +- shared-bindings/bitbangio/SPI.c | 11 +- shared-bindings/busio/I2C.c | 6 +- shared-bindings/busio/SPI.c | 11 +- shared-bindings/busio/UART.c | 7 +- shared-bindings/digitalio/DigitalInOut.c | 15 +- shared-bindings/gamepad/GamePad.c | 6 +- shared-bindings/help.c | 3 +- shared-bindings/math/__init__.c | 6 +- shared-bindings/microcontroller/Pin.c | 3 +- shared-bindings/microcontroller/__init__.c | 4 +- shared-bindings/multiterminal/__init__.c | 6 +- shared-bindings/multiterminal/__init__.h | 2 + shared-bindings/neopixel_write/__init__.c | 6 +- shared-bindings/nvm/ByteArray.c | 15 +- shared-bindings/pulseio/PWMOut.c | 7 +- shared-bindings/pulseio/PulseIn.c | 9 +- shared-bindings/pulseio/PulseOut.c | 5 +- shared-bindings/random/__init__.c | 11 +- shared-bindings/rtc/RTC.c | 7 +- shared-bindings/storage/__init__.c | 3 +- shared-bindings/struct/__init__.c | 6 +- shared-bindings/supervisor/__init__.c | 5 +- shared-bindings/time/__init__.c | 21 +- shared-bindings/touchio/TouchIn.c | 3 +- shared-bindings/util.c | 3 +- shared-module/audioio/WaveFile.c | 11 +- shared-module/bitbangio/I2C.c | 4 +- shared-module/bitbangio/SPI.c | 13 +- shared-module/struct/__init__.c | 10 +- supervisor/shared/translate.c | 42 ++ .../{messages/en-US.h => shared/translate.h} | 13 +- supervisor/supervisor.mk | 5 +- tools/build_adafruit_bins.sh | 77 +- tools/check_translations.py | 23 + tools/mpy-tool.py | 2 +- 80 files changed, 2531 insertions(+), 305 deletions(-) create mode 100644 locale/circuitpython.pot create mode 100644 locale/en_US.po create mode 100644 locale/es.po create mode 100644 supervisor/shared/translate.c rename supervisor/{messages/en-US.h => shared/translate.h} (79%) create mode 100644 tools/check_translations.py diff --git a/.travis.yml b/.travis.yml index edad9d4823..585e151336 100755 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,15 @@ compiler: git: depth: 1 env: + - TRAVIS_TEST=unix + - TRAVIS_TEST=docs + - TRAVIS_TEST=translations - TRAVIS_BOARD=feather_huzzah - - TRAVIS_BOARD=arduino_zero - TRAVIS_BOARD=circuitplayground_express + - TRAVIS_BOARD=pca10056 + - TRAVIS_BOARD=trinket_m0 + - TRAVIS_BOARD=feather_m4_express + - TRAVIS_BOARD=arduino_zero - TRAVIS_BOARD=circuitplayground_express_crickit - TRAVIS_BOARD=feather_m0_basic - TRAVIS_BOARD=feather_m0_adalogger @@ -16,19 +22,14 @@ env: - TRAVIS_BOARD=feather_m0_rfm9x - TRAVIS_BOARD=feather_m0_express - TRAVIS_BOARD=feather_m0_express_crickit - - TRAVIS_BOARD=feather_m4_express - TRAVIS_BOARD=itsybitsy_m0_express - TRAVIS_BOARD=itsybitsy_m4_express - TRAVIS_BOARD=metro_m0_express - TRAVIS_BOARD=metro_m4_express - TRAVIS_BOARD=pirkey_m0 - - TRAVIS_BOARD=trinket_m0 - TRAVIS_BOARD=gemma_m0 - TRAVIS_BOARD=hallowing_m0_express - TRAVIS_BOARD=feather52832 - - TRAVIS_BOARD=pca10056 - - TRAVIS_TEST=unix - - TRAVIS_TEST=docs addons: artifacts: @@ -56,8 +57,10 @@ before_script: # For huzzah builds - if [[ $TRAVIS_BOARD = "feather_huzzah" ]]; then wget https://github.com/jepler/esp-open-sdk/releases/download/2018-06-10/xtensa-lx106-elf-standalone.tar.gz && tar xavf xtensa-lx106-elf-standalone.tar.gz; PATH=$(readlink -f xtensa-lx106-elf/bin):$PATH; fi # For coverage testing (upgrade is used to get latest urllib3 version) + - ([[ -z "$TRAVIS_TEST" ]] || sudo apt-get install -y python3-pip) - ([[ -z "$TRAVIS_TEST" ]] || sudo pip install --upgrade cpp-coveralls) - ([[ $TRAVIS_TEST != "docs" ]] || sudo pip install Sphinx sphinx-rtd-theme recommonmark) + - ([[ $TRAVIS_TEST != "translations" ]] || sudo pip3 install polib) - gcc --version - ([[ -z "$TRAVIS_BOARD" ]] || arm-none-eabi-gcc --version) - python3 --version @@ -103,6 +106,9 @@ script: - ([[ $TRAVIS_TEST != "docs" ]] || sphinx-build -E -W -b html . _build/html) - echo -en 'travis_fold:end:build_docs\\r' + - (echo 'Building translations' && echo -en 'travis_fold:start:build_translations\\r') + - ([[ $TRAVIS_TEST != "translations" ]] || make check-translate) + - echo -en 'travis_fold:end:build_translations\\r' # run coveralls coverage analysis (try to, even if some builds/tests failed) #- (cd ports/unix && coveralls --root ../.. --build-root . --gcov $(which gcov) --gcov-options '\-o build-coverage/' --include py --include extmod) diff --git a/Makefile b/Makefile index 7251d4d17a..ca6647a0ef 100644 --- a/Makefile +++ b/Makefile @@ -17,10 +17,9 @@ CONFDIR = . FORCE = -E VERBOSE = -v -# User-friendly check for sphinx-build -ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) -$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) -endif +# Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the +# full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the +# executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 @@ -190,3 +189,15 @@ pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." + +# phony target so we always run +all-source: + +locale/circuitpython.pot: all-source + find . -iname "*.c" | xargs xgettext -L C --keyword=translate -o circuitpython.pot -p locale + +translate: locale/circuitpython.pot + for po in $(shell ls locale/*.po); do msgmerge -U $$po locale/circuitpython.pot; done + +check-translate: locale/circuitpython.pot $(wildcard locale/*.po) + $(PYTHON) tools/check_translations.py $^ diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot new file mode 100644 index 0000000000..b352963a7d --- /dev/null +++ b/locale/circuitpython.pot @@ -0,0 +1,673 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-08-03 17:20-0700\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: main.c:137 +msgid " output:\n" +msgstr "" + +#: main.c:148 main.c:221 +msgid "" +"Auto-reload is on. Simply save files over USB to run them or enter REPL to " +"disable.\n" +msgstr "" + +#: main.c:150 +msgid "Running in safe mode! Auto-reload is off.\n" +msgstr "" + +#: main.c:152 main.c:223 +msgid "Auto-reload is off.\n" +msgstr "" + +#: main.c:166 +msgid "Running in safe mode! Not running saved code.\n" +msgstr "" + +#: main.c:182 +msgid "WARNING: Your code filename has two extensions\n" +msgstr "" + +#: main.c:230 +msgid "You requested starting safe mode by " +msgstr "" + +#: main.c:233 +msgid "To exit, please reset the board without " +msgstr "" + +#: main.c:240 +msgid "" +"You are running in safe mode which means something really bad happened.\n" +msgstr "" + +#: main.c:242 +msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" +msgstr "" + +#: main.c:243 +msgid "Please file an issue here with the contents of your CIRCUITPY drive:\n" +msgstr "" + +#: main.c:246 +msgid "" +"The microcontroller's power dipped. Please make sure your power supply " +"provides\n" +msgstr "" + +#: main.c:247 +msgid "" +"enough power for the whole circuit and press reset (after ejecting " +"CIRCUITPY).\n" +msgstr "" + +#: main.c:251 +msgid "Press any key to enter the REPL. Use CTRL-D to reload." +msgstr "" + +#: main.c:406 +msgid "soft reboot\n" +msgstr "" + +#: ports/atmel-samd/common-hal/analogio/AnalogIn.c:63 +msgid "Pin does not have ADC capabilities" +msgstr "" + +#: ports/atmel-samd/common-hal/analogio/AnalogOut.c:53 +msgid "AnalogOut not supported on given pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:147 +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:150 +msgid "Invalid bit clock pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:153 +msgid "Bit clock and word select must share a clock unit" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:156 +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:130 +msgid "Invalid data pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:169 +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:174 +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:145 +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:150 +msgid "Serializer in use" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:230 +msgid "Clock unit in use" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:240 +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:172 +msgid "Unable to find free GCLK" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:254 +msgid "Too many channels in sample." +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:322 +msgid "No DMA channel found" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:324 +msgid "Unable to allocate buffers for signed conversion" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:109 +msgid "Invalid clock pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:134 +msgid "Only 8 or 16 bit mono with " +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:167 +msgid "sampling rate out of range" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:69 +msgid "DAC already in use" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:73 +msgid "Right channel unsupported" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:76 +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:116 +#: ports/atmel-samd/common-hal/touchio/TouchIn.c:65 +msgid "Invalid pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:84 +msgid "Invalid pin for left channel" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:88 +msgid "Invalid pin for right channel" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:91 +msgid "Cannot output both channels on the same pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:173 +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:186 +#: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110 +msgid "All timers in use" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c:45 +msgid "Not enough pins available" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c:76 +#: ports/atmel-samd/common-hal/busio/UART.c:121 +msgid "Invalid pins" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c:99 +msgid "SDA or SCL needs a pull up" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c:119 +msgid "Unsupported baudrate" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:66 +msgid "bytes > 8 bits not supported" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:73 +msgid "tx and rx cannot both be None" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:142 +msgid "Failed to allocate RX buffer" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:151 +msgid "Could not initialize UART" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:239 +msgid "No RX pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:289 +msgid "No TX pin" +msgstr "" + +#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:168 +msgid "Cannot get pull while in output mode" +msgstr "" + +#: ports/atmel-samd/common-hal/microcontroller/__init__.c:74 +msgid "Cannot reset into bootloader because no bootloader is present." +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:120 +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:366 +msgid "Invalid PWM frequency" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:184 +msgid "All timers for this pin are in use" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:110 +msgid "No hardware support on pin" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:113 +msgid "EXTINT channel already in use" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:118 +#, c-format +msgid "Failed to allocate RX buffer of %d bytes" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:203 +msgid "pop from an empty PulseIn" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:235 +msgid "index out of range" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseOut.c:178 +msgid "Another send is already active" +msgstr "" + +#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c:38 +msgid "Both pins must support hardware interrupts" +msgstr "" + +#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c:46 +msgid "A hardware interrupt channel is already in use" +msgstr "" + +#: ports/atmel-samd/common-hal/rtc/RTC.c:101 +msgid "calibration value out of range +/-127" +msgstr "" + +#: ports/atmel-samd/common-hal/storage/__init__.c:48 +msgid "Cannot remount '/' when USB is active." +msgstr "" + +#: ports/atmel-samd/common-hal/touchio/TouchIn.c:75 +msgid "No free GCLKs" +msgstr "" + +#: ports/atmel-samd/common-hal/usb_hid/Device.c:78 +#, c-format +msgid "Buffer incorrect size. Should be %d bytes." +msgstr "" + +#: ports/atmel-samd/common-hal/usb_hid/Device.c:82 +msgid "USB Busy" +msgstr "" + +#: ports/atmel-samd/common-hal/usb_hid/Device.c:82 +msgid "USB Error" +msgstr "" + +#: py/modbuiltins.c:162 +msgid "chr() arg not in range(0x110000)" +msgstr "" + +#: py/modbuiltins.c:171 +msgid "chr() arg not in range(256)" +msgstr "" + +#: py/modbuiltins.c:285 +msgid "arg is an empty sequence" +msgstr "" + +#: py/modbuiltins.c:350 +msgid "ord expects a character" +msgstr "" + +#: py/modbuiltins.c:353 +#, c-format +msgid "ord() expected a character, but string of length %d found" +msgstr "" + +#: py/modbuiltins.c:363 +msgid "3-arg pow() not supported" +msgstr "" + +#: py/modbuiltins.c:517 +msgid "must use keyword argument for key function" +msgstr "" + +#: py/modstruct.c:145 py/modstruct.c:153 py/modstruct.c:234 py/modstruct.c:244 +#: shared-bindings/struct/__init__.c:103 shared-bindings/struct/__init__.c:145 +#: shared-module/struct/__init__.c:91 shared-module/struct/__init__.c:175 +msgid "buffer too small" +msgstr "" + +#: shared-bindings/_stage/Layer.c:71 +msgid "graphic must be 2048 bytes long" +msgstr "" + +#: shared-bindings/_stage/Layer.c:77 shared-bindings/_stage/Text.c:75 +msgid "palette must be 32 bytes long" +msgstr "" + +#: shared-bindings/_stage/Layer.c:84 +msgid "map buffer too small" +msgstr "" + +#: shared-bindings/_stage/Text.c:69 +msgid "font must be 2048 bytes long" +msgstr "" + +#: shared-bindings/_stage/Text.c:81 +msgid "chars buffer too small" +msgstr "" + +#: shared-bindings/analogio/AnalogOut.c:118 +msgid "AnalogOut is only 16 bits. Value must be less than 65536." +msgstr "" + +#: shared-bindings/audiobusio/I2SOut.c:225 +#: shared-bindings/audioio/AudioOut.c:223 +msgid "Not playing" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:124 +msgid "Bit depth must be multiple of 8." +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:128 +msgid "Oversample must be multiple of 8." +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:136 +msgid "Microphone startup delay must be in range 0.0 to 1.0" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:193 +msgid "destination_length must be an int >= 0" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:202 +msgid "Destination capacity is smaller than destination_length." +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:206 +msgid "destination buffer must be an array of type 'H' for bit_depth = 16" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:208 +msgid "" +"destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" +msgstr "" + +#: shared-bindings/audioio/RawSample.c:98 +msgid "" +"sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " +"'B'" +msgstr "" + +#: shared-bindings/audioio/RawSample.c:104 +msgid "buffer must be a bytes-like object" +msgstr "" + +#: shared-bindings/audioio/WaveFile.c:78 +msgid "file must be a file opened in byte mode" +msgstr "" + +#: shared-bindings/bitbangio/I2C.c:111 shared-bindings/bitbangio/SPI.c:121 +#: shared-bindings/busio/SPI.c:133 +msgid "Function requires lock" +msgstr "" + +#: shared-bindings/bitbangio/I2C.c:195 shared-bindings/busio/I2C.c:210 +msgid "Buffer must be at least length 1" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:168 +msgid "Invalid polarity" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:172 +msgid "Invalid phase" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:176 +msgid "Invalid number of bits" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:341 +msgid "buffer slices must be of equal length" +msgstr "" + +#: shared-bindings/busio/I2C.c:120 +msgid "Function requires lock." +msgstr "" + +#: shared-bindings/busio/UART.c:98 +msgid "bits must be 7, 8 or 9" +msgstr "" + +#: shared-bindings/busio/UART.c:110 +msgid "stop must be 1 or 2" +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:211 +msgid "Invalid direction." +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:240 +msgid "Cannot set value when direction is input." +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:266 +#: shared-bindings/digitalio/DigitalInOut.c:281 +msgid "Drive mode not used when direction is input." +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:314 +#: shared-bindings/digitalio/DigitalInOut.c:331 +msgid "Pull not used when direction is output." +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:340 +msgid "Unsupported pull value." +msgstr "" + +#: shared-bindings/gamepad/GamePad.c:100 +msgid "too many arguments" +msgstr "" + +#: shared-bindings/gamepad/GamePad.c:104 +msgid "expected a DigitalInOut" +msgstr "" + +#: shared-bindings/math/__init__.c:53 +msgid "math domain error" +msgstr "" + +#: shared-bindings/math/__init__.c:346 +msgid "division by zero" +msgstr "" + +#: shared-bindings/microcontroller/Pin.c:89 +#: shared-bindings/neopixel_write/__init__.c:67 +#: shared-bindings/pulseio/PulseOut.c:75 +msgid "Expected a %q" +msgstr "" + +#: shared-bindings/microcontroller/__init__.c:126 +msgid "Invalid run mode." +msgstr "" + +#: shared-bindings/multiterminal/__init__.c:68 +msgid "Stream missing readinto() or write() method." +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:85 +msgid "only slices with step=1 (aka None) are supported" +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:99 +msgid "Slice and value different lengths." +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:104 +msgid "Array values should be single bytes." +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:107 +msgid "array/bytes required on right side" +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:111 shared-bindings/nvm/ByteArray.c:141 +msgid "Unable to write to nvm." +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:137 +msgid "Bytes must be between 0 and 255." +msgstr "" + +#: shared-bindings/pulseio/PWMOut.c:164 +msgid "" +"PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)" +msgstr "" + +#: shared-bindings/pulseio/PWMOut.c:195 +msgid "" +"PWM frequency not writeable when variable_frequency is False on construction." +msgstr "" + +#: shared-bindings/pulseio/PulseIn.c:275 +msgid "Cannot delete values" +msgstr "" + +#: shared-bindings/pulseio/PulseIn.c:281 +msgid "Slices not supported" +msgstr "" + +#: shared-bindings/pulseio/PulseIn.c:287 +msgid "index must be int" +msgstr "" + +#: shared-bindings/pulseio/PulseIn.c:293 +msgid "Read-only" +msgstr "" + +#: shared-bindings/pulseio/PulseOut.c:134 +msgid "Array must contain halfwords (type 'H')" +msgstr "" + +#: shared-bindings/random/__init__.c:92 shared-bindings/random/__init__.c:100 +msgid "stop not reachable from start" +msgstr "" + +#: shared-bindings/random/__init__.c:111 +msgid "step must be non-zero" +msgstr "" + +#: shared-bindings/random/__init__.c:114 +msgid "invalid step" +msgstr "" + +#: shared-bindings/random/__init__.c:146 +msgid "empty sequence" +msgstr "" + +#: shared-bindings/rtc/RTC.c:40 shared-bindings/rtc/RTC.c:44 +#: shared-bindings/time/__init__.c:192 +msgid "RTC is not supported on this board" +msgstr "" + +#: shared-bindings/rtc/RTC.c:52 +msgid "RTC calibration is not supported on this board" +msgstr "" + +#: shared-bindings/storage/__init__.c:77 +msgid "filesystem must provide mount method" +msgstr "" + +#: shared-bindings/supervisor/__init__.c:93 +msgid "Brightness must be between 0 and 255" +msgstr "" + +#: shared-bindings/supervisor/__init__.c:119 +msgid "Stack size must be at least 256" +msgstr "" + +#: shared-bindings/time/__init__.c:80 +msgid "sleep length must be non-negative" +msgstr "" + +#: shared-bindings/time/__init__.c:90 +msgid "time.struct_time() takes exactly 1 argument" +msgstr "" + +#: shared-bindings/time/__init__.c:93 +msgid "time.struct_time() takes a 9-sequence" +msgstr "" + +#: shared-bindings/time/__init__.c:171 shared-bindings/time/__init__.c:252 +msgid "Tuple or struct_time argument required" +msgstr "" + +#: shared-bindings/time/__init__.c:176 shared-bindings/time/__init__.c:257 +msgid "function takes exactly 9 arguments" +msgstr "" + +#: shared-bindings/time/__init__.c:228 shared-bindings/time/__init__.c:261 +msgid "timestamp out of range for platform time_t" +msgstr "" + +#: shared-bindings/touchio/TouchIn.c:173 +msgid "threshold must be in the range 0-65536" +msgstr "" + +#: shared-bindings/util.c:38 +msgid "" +"Object has been deinitialized and can no longer be used. Create a new object." +msgstr "" + +#: shared-module/audioio/WaveFile.c:61 +msgid "Invalid wave file" +msgstr "" + +#: shared-module/audioio/WaveFile.c:69 +msgid "Invalid format chunk size" +msgstr "" + +#: shared-module/audioio/WaveFile.c:83 +msgid "Unsupported format" +msgstr "" + +#: shared-module/audioio/WaveFile.c:99 +msgid "Data chunk must follow fmt chunk" +msgstr "" + +#: shared-module/audioio/WaveFile.c:107 +msgid "Invalid file" +msgstr "" + +#: shared-module/bitbangio/I2C.c:58 +msgid "Clock stretch too long" +msgstr "" + +#: shared-module/bitbangio/SPI.c:45 +msgid "Clock pin init failed." +msgstr "" + +#: shared-module/bitbangio/SPI.c:51 +msgid "MOSI pin init failed." +msgstr "" + +#: shared-module/bitbangio/SPI.c:62 +msgid "MISO pin init failed." +msgstr "" + +#: shared-module/bitbangio/SPI.c:122 +msgid "Cannot write without MOSI pin." +msgstr "" + +#: shared-module/bitbangio/SPI.c:177 +msgid "Cannot read without MISO pin." +msgstr "" + +#: shared-module/bitbangio/SPI.c:241 +msgid "Cannot transfer without MOSI and MISO pins." +msgstr "" + +#: shared-module/struct/__init__.c:39 +msgid "'S' and 'O' are not supported format types" +msgstr "" + +#: shared-module/struct/__init__.c:83 +msgid "too many arguments provided with the given format" +msgstr "" diff --git a/locale/en_US.po b/locale/en_US.po new file mode 100644 index 0000000000..60dcc4353b --- /dev/null +++ b/locale/en_US.po @@ -0,0 +1,673 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-08-03 17:20-0700\n" +"PO-Revision-Date: 2018-07-27 11:55-0700\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.1.1\n" + +#: main.c:137 +msgid " output:\n" +msgstr "" + +#: main.c:148 main.c:221 +msgid "" +"Auto-reload is on. Simply save files over USB to run them or enter REPL to " +"disable.\n" +msgstr "" + +#: main.c:150 +msgid "Running in safe mode! Auto-reload is off.\n" +msgstr "" + +#: main.c:152 main.c:223 +msgid "Auto-reload is off.\n" +msgstr "" + +#: main.c:166 +msgid "Running in safe mode! Not running saved code.\n" +msgstr "" + +#: main.c:182 +msgid "WARNING: Your code filename has two extensions\n" +msgstr "" + +#: main.c:230 +msgid "You requested starting safe mode by " +msgstr "" + +#: main.c:233 +msgid "To exit, please reset the board without " +msgstr "" + +#: main.c:240 +msgid "" +"You are running in safe mode which means something really bad happened.\n" +msgstr "" + +#: main.c:242 +msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" +msgstr "" + +#: main.c:243 +msgid "Please file an issue here with the contents of your CIRCUITPY drive:\n" +msgstr "" + +#: main.c:246 +msgid "" +"The microcontroller's power dipped. Please make sure your power supply " +"provides\n" +msgstr "" + +#: main.c:247 +msgid "" +"enough power for the whole circuit and press reset (after ejecting " +"CIRCUITPY).\n" +msgstr "" + +#: main.c:251 +msgid "Press any key to enter the REPL. Use CTRL-D to reload." +msgstr "" + +#: main.c:406 +msgid "soft reboot\n" +msgstr "" + +#: ports/atmel-samd/common-hal/analogio/AnalogIn.c:63 +msgid "Pin does not have ADC capabilities" +msgstr "" + +#: ports/atmel-samd/common-hal/analogio/AnalogOut.c:53 +msgid "AnalogOut not supported on given pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:147 +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:150 +msgid "Invalid bit clock pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:153 +msgid "Bit clock and word select must share a clock unit" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:156 +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:130 +msgid "Invalid data pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:169 +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:174 +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:145 +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:150 +msgid "Serializer in use" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:230 +msgid "Clock unit in use" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:240 +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:172 +msgid "Unable to find free GCLK" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:254 +msgid "Too many channels in sample." +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:322 +msgid "No DMA channel found" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:324 +msgid "Unable to allocate buffers for signed conversion" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:109 +msgid "Invalid clock pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:134 +msgid "Only 8 or 16 bit mono with " +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:167 +msgid "sampling rate out of range" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:69 +msgid "DAC already in use" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:73 +msgid "Right channel unsupported" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:76 +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:116 +#: ports/atmel-samd/common-hal/touchio/TouchIn.c:65 +msgid "Invalid pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:84 +msgid "Invalid pin for left channel" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:88 +msgid "Invalid pin for right channel" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:91 +msgid "Cannot output both channels on the same pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:173 +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:186 +#: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110 +msgid "All timers in use" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c:45 +msgid "Not enough pins available" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c:76 +#: ports/atmel-samd/common-hal/busio/UART.c:121 +msgid "Invalid pins" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c:99 +msgid "SDA or SCL needs a pull up" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c:119 +msgid "Unsupported baudrate" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:66 +msgid "bytes > 8 bits not supported" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:73 +msgid "tx and rx cannot both be None" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:142 +msgid "Failed to allocate RX buffer" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:151 +msgid "Could not initialize UART" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:239 +msgid "No RX pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:289 +msgid "No TX pin" +msgstr "" + +#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:168 +msgid "Cannot get pull while in output mode" +msgstr "" + +#: ports/atmel-samd/common-hal/microcontroller/__init__.c:74 +msgid "Cannot reset into bootloader because no bootloader is present." +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:120 +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:366 +msgid "Invalid PWM frequency" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:184 +msgid "All timers for this pin are in use" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:110 +msgid "No hardware support on pin" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:113 +msgid "EXTINT channel already in use" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:118 +#, c-format +msgid "Failed to allocate RX buffer of %d bytes" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:203 +msgid "pop from an empty PulseIn" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:235 +msgid "index out of range" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseOut.c:178 +msgid "Another send is already active" +msgstr "" + +#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c:38 +msgid "Both pins must support hardware interrupts" +msgstr "" + +#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c:46 +msgid "A hardware interrupt channel is already in use" +msgstr "" + +#: ports/atmel-samd/common-hal/rtc/RTC.c:101 +msgid "calibration value out of range +/-127" +msgstr "" + +#: ports/atmel-samd/common-hal/storage/__init__.c:48 +msgid "Cannot remount '/' when USB is active." +msgstr "" + +#: ports/atmel-samd/common-hal/touchio/TouchIn.c:75 +msgid "No free GCLKs" +msgstr "" + +#: ports/atmel-samd/common-hal/usb_hid/Device.c:78 +#, c-format +msgid "Buffer incorrect size. Should be %d bytes." +msgstr "" + +#: ports/atmel-samd/common-hal/usb_hid/Device.c:82 +msgid "USB Busy" +msgstr "" + +#: ports/atmel-samd/common-hal/usb_hid/Device.c:82 +msgid "USB Error" +msgstr "" + +#: py/modbuiltins.c:162 +msgid "chr() arg not in range(0x110000)" +msgstr "" + +#: py/modbuiltins.c:171 +msgid "chr() arg not in range(256)" +msgstr "" + +#: py/modbuiltins.c:285 +msgid "arg is an empty sequence" +msgstr "" + +#: py/modbuiltins.c:350 +msgid "ord expects a character" +msgstr "" + +#: py/modbuiltins.c:353 +#, c-format +msgid "ord() expected a character, but string of length %d found" +msgstr "" + +#: py/modbuiltins.c:363 +msgid "3-arg pow() not supported" +msgstr "" + +#: py/modbuiltins.c:517 +msgid "must use keyword argument for key function" +msgstr "" + +#: py/modstruct.c:145 py/modstruct.c:153 py/modstruct.c:234 py/modstruct.c:244 +#: shared-bindings/struct/__init__.c:103 shared-bindings/struct/__init__.c:145 +#: shared-module/struct/__init__.c:91 shared-module/struct/__init__.c:175 +msgid "buffer too small" +msgstr "" + +#: shared-bindings/_stage/Layer.c:71 +msgid "graphic must be 2048 bytes long" +msgstr "" + +#: shared-bindings/_stage/Layer.c:77 shared-bindings/_stage/Text.c:75 +msgid "palette must be 32 bytes long" +msgstr "" + +#: shared-bindings/_stage/Layer.c:84 +msgid "map buffer too small" +msgstr "" + +#: shared-bindings/_stage/Text.c:69 +msgid "font must be 2048 bytes long" +msgstr "" + +#: shared-bindings/_stage/Text.c:81 +msgid "chars buffer too small" +msgstr "" + +#: shared-bindings/analogio/AnalogOut.c:118 +msgid "AnalogOut is only 16 bits. Value must be less than 65536." +msgstr "" + +#: shared-bindings/audiobusio/I2SOut.c:225 +#: shared-bindings/audioio/AudioOut.c:223 +msgid "Not playing" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:124 +msgid "Bit depth must be multiple of 8." +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:128 +msgid "Oversample must be multiple of 8." +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:136 +msgid "Microphone startup delay must be in range 0.0 to 1.0" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:193 +msgid "destination_length must be an int >= 0" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:202 +msgid "Destination capacity is smaller than destination_length." +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:206 +msgid "destination buffer must be an array of type 'H' for bit_depth = 16" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:208 +msgid "" +"destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" +msgstr "" + +#: shared-bindings/audioio/RawSample.c:98 +msgid "" +"sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " +"'B'" +msgstr "" + +#: shared-bindings/audioio/RawSample.c:104 +msgid "buffer must be a bytes-like object" +msgstr "" + +#: shared-bindings/audioio/WaveFile.c:78 +msgid "file must be a file opened in byte mode" +msgstr "" + +#: shared-bindings/bitbangio/I2C.c:111 shared-bindings/bitbangio/SPI.c:121 +#: shared-bindings/busio/SPI.c:133 +msgid "Function requires lock" +msgstr "" + +#: shared-bindings/bitbangio/I2C.c:195 shared-bindings/busio/I2C.c:210 +msgid "Buffer must be at least length 1" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:168 +msgid "Invalid polarity" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:172 +msgid "Invalid phase" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:176 +msgid "Invalid number of bits" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:341 +msgid "buffer slices must be of equal length" +msgstr "" + +#: shared-bindings/busio/I2C.c:120 +msgid "Function requires lock." +msgstr "" + +#: shared-bindings/busio/UART.c:98 +msgid "bits must be 7, 8 or 9" +msgstr "" + +#: shared-bindings/busio/UART.c:110 +msgid "stop must be 1 or 2" +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:211 +msgid "Invalid direction." +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:240 +msgid "Cannot set value when direction is input." +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:266 +#: shared-bindings/digitalio/DigitalInOut.c:281 +msgid "Drive mode not used when direction is input." +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:314 +#: shared-bindings/digitalio/DigitalInOut.c:331 +msgid "Pull not used when direction is output." +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:340 +msgid "Unsupported pull value." +msgstr "" + +#: shared-bindings/gamepad/GamePad.c:100 +msgid "too many arguments" +msgstr "" + +#: shared-bindings/gamepad/GamePad.c:104 +msgid "expected a DigitalInOut" +msgstr "" + +#: shared-bindings/math/__init__.c:53 +msgid "math domain error" +msgstr "" + +#: shared-bindings/math/__init__.c:346 +msgid "division by zero" +msgstr "" + +#: shared-bindings/microcontroller/Pin.c:89 +#: shared-bindings/neopixel_write/__init__.c:67 +#: shared-bindings/pulseio/PulseOut.c:75 +msgid "Expected a %q" +msgstr "" + +#: shared-bindings/microcontroller/__init__.c:126 +msgid "Invalid run mode." +msgstr "" + +#: shared-bindings/multiterminal/__init__.c:68 +msgid "Stream missing readinto() or write() method." +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:85 +msgid "only slices with step=1 (aka None) are supported" +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:99 +msgid "Slice and value different lengths." +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:104 +msgid "Array values should be single bytes." +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:107 +msgid "array/bytes required on right side" +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:111 shared-bindings/nvm/ByteArray.c:141 +msgid "Unable to write to nvm." +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:137 +msgid "Bytes must be between 0 and 255." +msgstr "" + +#: shared-bindings/pulseio/PWMOut.c:164 +msgid "" +"PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)" +msgstr "" + +#: shared-bindings/pulseio/PWMOut.c:195 +msgid "" +"PWM frequency not writeable when variable_frequency is False on construction." +msgstr "" + +#: shared-bindings/pulseio/PulseIn.c:275 +msgid "Cannot delete values" +msgstr "" + +#: shared-bindings/pulseio/PulseIn.c:281 +msgid "Slices not supported" +msgstr "" + +#: shared-bindings/pulseio/PulseIn.c:287 +msgid "index must be int" +msgstr "" + +#: shared-bindings/pulseio/PulseIn.c:293 +msgid "Read-only" +msgstr "" + +#: shared-bindings/pulseio/PulseOut.c:134 +msgid "Array must contain halfwords (type 'H')" +msgstr "" + +#: shared-bindings/random/__init__.c:92 shared-bindings/random/__init__.c:100 +msgid "stop not reachable from start" +msgstr "" + +#: shared-bindings/random/__init__.c:111 +msgid "step must be non-zero" +msgstr "" + +#: shared-bindings/random/__init__.c:114 +msgid "invalid step" +msgstr "" + +#: shared-bindings/random/__init__.c:146 +msgid "empty sequence" +msgstr "" + +#: shared-bindings/rtc/RTC.c:40 shared-bindings/rtc/RTC.c:44 +#: shared-bindings/time/__init__.c:192 +msgid "RTC is not supported on this board" +msgstr "" + +#: shared-bindings/rtc/RTC.c:52 +msgid "RTC calibration is not supported on this board" +msgstr "" + +#: shared-bindings/storage/__init__.c:77 +msgid "filesystem must provide mount method" +msgstr "" + +#: shared-bindings/supervisor/__init__.c:93 +msgid "Brightness must be between 0 and 255" +msgstr "" + +#: shared-bindings/supervisor/__init__.c:119 +msgid "Stack size must be at least 256" +msgstr "" + +#: shared-bindings/time/__init__.c:80 +msgid "sleep length must be non-negative" +msgstr "" + +#: shared-bindings/time/__init__.c:90 +msgid "time.struct_time() takes exactly 1 argument" +msgstr "" + +#: shared-bindings/time/__init__.c:93 +msgid "time.struct_time() takes a 9-sequence" +msgstr "" + +#: shared-bindings/time/__init__.c:171 shared-bindings/time/__init__.c:252 +msgid "Tuple or struct_time argument required" +msgstr "" + +#: shared-bindings/time/__init__.c:176 shared-bindings/time/__init__.c:257 +msgid "function takes exactly 9 arguments" +msgstr "" + +#: shared-bindings/time/__init__.c:228 shared-bindings/time/__init__.c:261 +msgid "timestamp out of range for platform time_t" +msgstr "" + +#: shared-bindings/touchio/TouchIn.c:173 +msgid "threshold must be in the range 0-65536" +msgstr "" + +#: shared-bindings/util.c:38 +msgid "" +"Object has been deinitialized and can no longer be used. Create a new object." +msgstr "" + +#: shared-module/audioio/WaveFile.c:61 +msgid "Invalid wave file" +msgstr "" + +#: shared-module/audioio/WaveFile.c:69 +msgid "Invalid format chunk size" +msgstr "" + +#: shared-module/audioio/WaveFile.c:83 +msgid "Unsupported format" +msgstr "" + +#: shared-module/audioio/WaveFile.c:99 +msgid "Data chunk must follow fmt chunk" +msgstr "" + +#: shared-module/audioio/WaveFile.c:107 +msgid "Invalid file" +msgstr "" + +#: shared-module/bitbangio/I2C.c:58 +msgid "Clock stretch too long" +msgstr "" + +#: shared-module/bitbangio/SPI.c:45 +msgid "Clock pin init failed." +msgstr "" + +#: shared-module/bitbangio/SPI.c:51 +msgid "MOSI pin init failed." +msgstr "" + +#: shared-module/bitbangio/SPI.c:62 +msgid "MISO pin init failed." +msgstr "" + +#: shared-module/bitbangio/SPI.c:122 +msgid "Cannot write without MOSI pin." +msgstr "" + +#: shared-module/bitbangio/SPI.c:177 +msgid "Cannot read without MISO pin." +msgstr "" + +#: shared-module/bitbangio/SPI.c:241 +msgid "Cannot transfer without MOSI and MISO pins." +msgstr "" + +#: shared-module/struct/__init__.c:39 +msgid "'S' and 'O' are not supported format types" +msgstr "" + +#: shared-module/struct/__init__.c:83 +msgid "too many arguments provided with the given format" +msgstr "" diff --git a/locale/es.po b/locale/es.po new file mode 100644 index 0000000000..60dcc4353b --- /dev/null +++ b/locale/es.po @@ -0,0 +1,673 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-08-03 17:20-0700\n" +"PO-Revision-Date: 2018-07-27 11:55-0700\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 2.1.1\n" + +#: main.c:137 +msgid " output:\n" +msgstr "" + +#: main.c:148 main.c:221 +msgid "" +"Auto-reload is on. Simply save files over USB to run them or enter REPL to " +"disable.\n" +msgstr "" + +#: main.c:150 +msgid "Running in safe mode! Auto-reload is off.\n" +msgstr "" + +#: main.c:152 main.c:223 +msgid "Auto-reload is off.\n" +msgstr "" + +#: main.c:166 +msgid "Running in safe mode! Not running saved code.\n" +msgstr "" + +#: main.c:182 +msgid "WARNING: Your code filename has two extensions\n" +msgstr "" + +#: main.c:230 +msgid "You requested starting safe mode by " +msgstr "" + +#: main.c:233 +msgid "To exit, please reset the board without " +msgstr "" + +#: main.c:240 +msgid "" +"You are running in safe mode which means something really bad happened.\n" +msgstr "" + +#: main.c:242 +msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" +msgstr "" + +#: main.c:243 +msgid "Please file an issue here with the contents of your CIRCUITPY drive:\n" +msgstr "" + +#: main.c:246 +msgid "" +"The microcontroller's power dipped. Please make sure your power supply " +"provides\n" +msgstr "" + +#: main.c:247 +msgid "" +"enough power for the whole circuit and press reset (after ejecting " +"CIRCUITPY).\n" +msgstr "" + +#: main.c:251 +msgid "Press any key to enter the REPL. Use CTRL-D to reload." +msgstr "" + +#: main.c:406 +msgid "soft reboot\n" +msgstr "" + +#: ports/atmel-samd/common-hal/analogio/AnalogIn.c:63 +msgid "Pin does not have ADC capabilities" +msgstr "" + +#: ports/atmel-samd/common-hal/analogio/AnalogOut.c:53 +msgid "AnalogOut not supported on given pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:147 +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:150 +msgid "Invalid bit clock pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:153 +msgid "Bit clock and word select must share a clock unit" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:156 +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:130 +msgid "Invalid data pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:169 +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:174 +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:145 +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:150 +msgid "Serializer in use" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:230 +msgid "Clock unit in use" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:240 +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:172 +msgid "Unable to find free GCLK" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:254 +msgid "Too many channels in sample." +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:322 +msgid "No DMA channel found" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:308 +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:324 +msgid "Unable to allocate buffers for signed conversion" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:109 +msgid "Invalid clock pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:134 +msgid "Only 8 or 16 bit mono with " +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:167 +msgid "sampling rate out of range" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:69 +msgid "DAC already in use" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:73 +msgid "Right channel unsupported" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:76 +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:116 +#: ports/atmel-samd/common-hal/touchio/TouchIn.c:65 +msgid "Invalid pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:84 +msgid "Invalid pin for left channel" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:88 +msgid "Invalid pin for right channel" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:91 +msgid "Cannot output both channels on the same pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c:173 +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:186 +#: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110 +msgid "All timers in use" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c:45 +msgid "Not enough pins available" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c:76 +#: ports/atmel-samd/common-hal/busio/UART.c:121 +msgid "Invalid pins" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c:99 +msgid "SDA or SCL needs a pull up" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c:119 +msgid "Unsupported baudrate" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:66 +msgid "bytes > 8 bits not supported" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:73 +msgid "tx and rx cannot both be None" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:142 +msgid "Failed to allocate RX buffer" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:151 +msgid "Could not initialize UART" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:239 +msgid "No RX pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c:289 +msgid "No TX pin" +msgstr "" + +#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:168 +msgid "Cannot get pull while in output mode" +msgstr "" + +#: ports/atmel-samd/common-hal/microcontroller/__init__.c:74 +msgid "Cannot reset into bootloader because no bootloader is present." +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:120 +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:366 +msgid "Invalid PWM frequency" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PWMOut.c:184 +msgid "All timers for this pin are in use" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:110 +msgid "No hardware support on pin" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:113 +msgid "EXTINT channel already in use" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:118 +#, c-format +msgid "Failed to allocate RX buffer of %d bytes" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:203 +msgid "pop from an empty PulseIn" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c:235 +msgid "index out of range" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseOut.c:178 +msgid "Another send is already active" +msgstr "" + +#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c:38 +msgid "Both pins must support hardware interrupts" +msgstr "" + +#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c:46 +msgid "A hardware interrupt channel is already in use" +msgstr "" + +#: ports/atmel-samd/common-hal/rtc/RTC.c:101 +msgid "calibration value out of range +/-127" +msgstr "" + +#: ports/atmel-samd/common-hal/storage/__init__.c:48 +msgid "Cannot remount '/' when USB is active." +msgstr "" + +#: ports/atmel-samd/common-hal/touchio/TouchIn.c:75 +msgid "No free GCLKs" +msgstr "" + +#: ports/atmel-samd/common-hal/usb_hid/Device.c:78 +#, c-format +msgid "Buffer incorrect size. Should be %d bytes." +msgstr "" + +#: ports/atmel-samd/common-hal/usb_hid/Device.c:82 +msgid "USB Busy" +msgstr "" + +#: ports/atmel-samd/common-hal/usb_hid/Device.c:82 +msgid "USB Error" +msgstr "" + +#: py/modbuiltins.c:162 +msgid "chr() arg not in range(0x110000)" +msgstr "" + +#: py/modbuiltins.c:171 +msgid "chr() arg not in range(256)" +msgstr "" + +#: py/modbuiltins.c:285 +msgid "arg is an empty sequence" +msgstr "" + +#: py/modbuiltins.c:350 +msgid "ord expects a character" +msgstr "" + +#: py/modbuiltins.c:353 +#, c-format +msgid "ord() expected a character, but string of length %d found" +msgstr "" + +#: py/modbuiltins.c:363 +msgid "3-arg pow() not supported" +msgstr "" + +#: py/modbuiltins.c:517 +msgid "must use keyword argument for key function" +msgstr "" + +#: py/modstruct.c:145 py/modstruct.c:153 py/modstruct.c:234 py/modstruct.c:244 +#: shared-bindings/struct/__init__.c:103 shared-bindings/struct/__init__.c:145 +#: shared-module/struct/__init__.c:91 shared-module/struct/__init__.c:175 +msgid "buffer too small" +msgstr "" + +#: shared-bindings/_stage/Layer.c:71 +msgid "graphic must be 2048 bytes long" +msgstr "" + +#: shared-bindings/_stage/Layer.c:77 shared-bindings/_stage/Text.c:75 +msgid "palette must be 32 bytes long" +msgstr "" + +#: shared-bindings/_stage/Layer.c:84 +msgid "map buffer too small" +msgstr "" + +#: shared-bindings/_stage/Text.c:69 +msgid "font must be 2048 bytes long" +msgstr "" + +#: shared-bindings/_stage/Text.c:81 +msgid "chars buffer too small" +msgstr "" + +#: shared-bindings/analogio/AnalogOut.c:118 +msgid "AnalogOut is only 16 bits. Value must be less than 65536." +msgstr "" + +#: shared-bindings/audiobusio/I2SOut.c:225 +#: shared-bindings/audioio/AudioOut.c:223 +msgid "Not playing" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:124 +msgid "Bit depth must be multiple of 8." +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:128 +msgid "Oversample must be multiple of 8." +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:136 +msgid "Microphone startup delay must be in range 0.0 to 1.0" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:193 +msgid "destination_length must be an int >= 0" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:202 +msgid "Destination capacity is smaller than destination_length." +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:206 +msgid "destination buffer must be an array of type 'H' for bit_depth = 16" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c:208 +msgid "" +"destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" +msgstr "" + +#: shared-bindings/audioio/RawSample.c:98 +msgid "" +"sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " +"'B'" +msgstr "" + +#: shared-bindings/audioio/RawSample.c:104 +msgid "buffer must be a bytes-like object" +msgstr "" + +#: shared-bindings/audioio/WaveFile.c:78 +msgid "file must be a file opened in byte mode" +msgstr "" + +#: shared-bindings/bitbangio/I2C.c:111 shared-bindings/bitbangio/SPI.c:121 +#: shared-bindings/busio/SPI.c:133 +msgid "Function requires lock" +msgstr "" + +#: shared-bindings/bitbangio/I2C.c:195 shared-bindings/busio/I2C.c:210 +msgid "Buffer must be at least length 1" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c:151 shared-bindings/busio/SPI.c:168 +msgid "Invalid polarity" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c:155 shared-bindings/busio/SPI.c:172 +msgid "Invalid phase" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c:159 shared-bindings/busio/SPI.c:176 +msgid "Invalid number of bits" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c:284 shared-bindings/busio/SPI.c:341 +msgid "buffer slices must be of equal length" +msgstr "" + +#: shared-bindings/busio/I2C.c:120 +msgid "Function requires lock." +msgstr "" + +#: shared-bindings/busio/UART.c:98 +msgid "bits must be 7, 8 or 9" +msgstr "" + +#: shared-bindings/busio/UART.c:110 +msgid "stop must be 1 or 2" +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:211 +msgid "Invalid direction." +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:240 +msgid "Cannot set value when direction is input." +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:266 +#: shared-bindings/digitalio/DigitalInOut.c:281 +msgid "Drive mode not used when direction is input." +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:314 +#: shared-bindings/digitalio/DigitalInOut.c:331 +msgid "Pull not used when direction is output." +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c:340 +msgid "Unsupported pull value." +msgstr "" + +#: shared-bindings/gamepad/GamePad.c:100 +msgid "too many arguments" +msgstr "" + +#: shared-bindings/gamepad/GamePad.c:104 +msgid "expected a DigitalInOut" +msgstr "" + +#: shared-bindings/math/__init__.c:53 +msgid "math domain error" +msgstr "" + +#: shared-bindings/math/__init__.c:346 +msgid "division by zero" +msgstr "" + +#: shared-bindings/microcontroller/Pin.c:89 +#: shared-bindings/neopixel_write/__init__.c:67 +#: shared-bindings/pulseio/PulseOut.c:75 +msgid "Expected a %q" +msgstr "" + +#: shared-bindings/microcontroller/__init__.c:126 +msgid "Invalid run mode." +msgstr "" + +#: shared-bindings/multiterminal/__init__.c:68 +msgid "Stream missing readinto() or write() method." +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:85 +msgid "only slices with step=1 (aka None) are supported" +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:99 +msgid "Slice and value different lengths." +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:104 +msgid "Array values should be single bytes." +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:107 +msgid "array/bytes required on right side" +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:111 shared-bindings/nvm/ByteArray.c:141 +msgid "Unable to write to nvm." +msgstr "" + +#: shared-bindings/nvm/ByteArray.c:137 +msgid "Bytes must be between 0 and 255." +msgstr "" + +#: shared-bindings/pulseio/PWMOut.c:164 +msgid "" +"PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)" +msgstr "" + +#: shared-bindings/pulseio/PWMOut.c:195 +msgid "" +"PWM frequency not writeable when variable_frequency is False on construction." +msgstr "" + +#: shared-bindings/pulseio/PulseIn.c:275 +msgid "Cannot delete values" +msgstr "" + +#: shared-bindings/pulseio/PulseIn.c:281 +msgid "Slices not supported" +msgstr "" + +#: shared-bindings/pulseio/PulseIn.c:287 +msgid "index must be int" +msgstr "" + +#: shared-bindings/pulseio/PulseIn.c:293 +msgid "Read-only" +msgstr "" + +#: shared-bindings/pulseio/PulseOut.c:134 +msgid "Array must contain halfwords (type 'H')" +msgstr "" + +#: shared-bindings/random/__init__.c:92 shared-bindings/random/__init__.c:100 +msgid "stop not reachable from start" +msgstr "" + +#: shared-bindings/random/__init__.c:111 +msgid "step must be non-zero" +msgstr "" + +#: shared-bindings/random/__init__.c:114 +msgid "invalid step" +msgstr "" + +#: shared-bindings/random/__init__.c:146 +msgid "empty sequence" +msgstr "" + +#: shared-bindings/rtc/RTC.c:40 shared-bindings/rtc/RTC.c:44 +#: shared-bindings/time/__init__.c:192 +msgid "RTC is not supported on this board" +msgstr "" + +#: shared-bindings/rtc/RTC.c:52 +msgid "RTC calibration is not supported on this board" +msgstr "" + +#: shared-bindings/storage/__init__.c:77 +msgid "filesystem must provide mount method" +msgstr "" + +#: shared-bindings/supervisor/__init__.c:93 +msgid "Brightness must be between 0 and 255" +msgstr "" + +#: shared-bindings/supervisor/__init__.c:119 +msgid "Stack size must be at least 256" +msgstr "" + +#: shared-bindings/time/__init__.c:80 +msgid "sleep length must be non-negative" +msgstr "" + +#: shared-bindings/time/__init__.c:90 +msgid "time.struct_time() takes exactly 1 argument" +msgstr "" + +#: shared-bindings/time/__init__.c:93 +msgid "time.struct_time() takes a 9-sequence" +msgstr "" + +#: shared-bindings/time/__init__.c:171 shared-bindings/time/__init__.c:252 +msgid "Tuple or struct_time argument required" +msgstr "" + +#: shared-bindings/time/__init__.c:176 shared-bindings/time/__init__.c:257 +msgid "function takes exactly 9 arguments" +msgstr "" + +#: shared-bindings/time/__init__.c:228 shared-bindings/time/__init__.c:261 +msgid "timestamp out of range for platform time_t" +msgstr "" + +#: shared-bindings/touchio/TouchIn.c:173 +msgid "threshold must be in the range 0-65536" +msgstr "" + +#: shared-bindings/util.c:38 +msgid "" +"Object has been deinitialized and can no longer be used. Create a new object." +msgstr "" + +#: shared-module/audioio/WaveFile.c:61 +msgid "Invalid wave file" +msgstr "" + +#: shared-module/audioio/WaveFile.c:69 +msgid "Invalid format chunk size" +msgstr "" + +#: shared-module/audioio/WaveFile.c:83 +msgid "Unsupported format" +msgstr "" + +#: shared-module/audioio/WaveFile.c:99 +msgid "Data chunk must follow fmt chunk" +msgstr "" + +#: shared-module/audioio/WaveFile.c:107 +msgid "Invalid file" +msgstr "" + +#: shared-module/bitbangio/I2C.c:58 +msgid "Clock stretch too long" +msgstr "" + +#: shared-module/bitbangio/SPI.c:45 +msgid "Clock pin init failed." +msgstr "" + +#: shared-module/bitbangio/SPI.c:51 +msgid "MOSI pin init failed." +msgstr "" + +#: shared-module/bitbangio/SPI.c:62 +msgid "MISO pin init failed." +msgstr "" + +#: shared-module/bitbangio/SPI.c:122 +msgid "Cannot write without MOSI pin." +msgstr "" + +#: shared-module/bitbangio/SPI.c:177 +msgid "Cannot read without MISO pin." +msgstr "" + +#: shared-module/bitbangio/SPI.c:241 +msgid "Cannot transfer without MOSI and MISO pins." +msgstr "" + +#: shared-module/struct/__init__.c:39 +msgid "'S' and 'O' are not supported format types" +msgstr "" + +#: shared-module/struct/__init__.c:83 +msgid "too many arguments provided with the given format" +msgstr "" diff --git a/main.c b/main.c index 7760d39f58..4bc9c279f3 100755 --- a/main.c +++ b/main.c @@ -48,9 +48,8 @@ #include "supervisor/memory.h" #include "supervisor/port.h" #include "supervisor/filesystem.h" -// TODO(tannewt): Figure out how to choose language at compile time. -#include "supervisor/messages/en-US.h" #include "supervisor/shared/autoreload.h" +#include "supervisor/shared/translate.h" #include "supervisor/shared/rgb_led_status.h" #include "supervisor/shared/stack.h" #include "supervisor/serial.h" @@ -135,7 +134,7 @@ bool maybe_run_list(const char ** filenames, pyexec_result_t* exec_result) { return false; } mp_hal_stdout_tx_str(filename); - mp_hal_stdout_tx_str(MSG_OUTPUT_SUFFIX); + mp_hal_stdout_tx_str(translate(" output:\n")); pyexec_file(filename, exec_result); return true; } @@ -144,13 +143,13 @@ bool run_code_py(safe_mode_t safe_mode) { bool serial_connected_at_start = serial_connected(); #ifdef CIRCUITPY_AUTORELOAD_DELAY_MS if (serial_connected_at_start) { - serial_write(MSG_NEWLINE); + serial_write("\n"); if (autoreload_is_enabled()) { - serial_write(MSG_AUTORELOAD_ON); + serial_write(translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n")); } else if (safe_mode != NO_SAFE_MODE) { - serial_write(MSG_SAFE_MODE_ON); + serial_write(translate("Running in safe mode! Auto-reload is off.\n")); } else if (!autoreload_is_enabled()) { - serial_write(MSG_AUTORELOAD_OFF); + serial_write(translate("Auto-reload is off.\n")); } } #endif @@ -164,7 +163,7 @@ bool run_code_py(safe_mode_t safe_mode) { bool found_main = false; if (safe_mode != NO_SAFE_MODE) { - serial_write(MSG_SAFE_MODE_NO_MAIN); + serial_write(translate("Running in safe mode! Not running saved code.\n")); } else { new_status_color(MAIN_RUNNING); @@ -180,7 +179,7 @@ bool run_code_py(safe_mode_t safe_mode) { if (!found_main){ found_main = maybe_run_list(double_extension_filenames, &result); if (found_main) { - serial_write(MSG_DOUBLE_FILE_EXTENSION); + serial_write(translate("WARNING: Your code filename has two extensions\n")); } } stop_mp(); @@ -214,38 +213,42 @@ bool run_code_py(safe_mode_t safe_mode) { if (!serial_connected_before_animation && serial_connected()) { if (serial_connected_at_start) { - serial_write(MSG_NEWLINE MSG_NEWLINE); + serial_write("\n\n"); } if (!serial_connected_at_start) { if (autoreload_is_enabled()) { - serial_write(MSG_AUTORELOAD_ON); + serial_write(translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n")); } else { - serial_write(MSG_AUTORELOAD_OFF); + serial_write(translate("Auto-reload is off.\n")); } } // Output a user safe mode string if its set. #ifdef BOARD_USER_SAFE_MODE if (safe_mode == USER_SAFE_MODE) { - serial_write(MSG_NEWLINE MSG_SAFE_MODE_USER_REQUESTED); + serial_write("\n"); + serial_write(translate("You requested starting safe mode by ")); serial_write(BOARD_USER_SAFE_MODE_ACTION); - serial_write(MSG_NEWLINE MSG_SAFE_MODE_USER_EXIT); + serial_write("\n"); + serial_write(translate("To exit, please reset the board without ")); serial_write(BOARD_USER_SAFE_MODE_ACTION); - serial_write(MSG_NEWLINE); + serial_write("\n"); } else #endif if (safe_mode != NO_SAFE_MODE) { - serial_write(MSG_NEWLINE MSG_BAD_SAFE_MODE MSG_NEWLINE); + serial_write("\n"); + serial_write(translate("You are running in safe mode which means something really bad happened.\n")); if (safe_mode == HARD_CRASH) { - serial_write(MSG_SAFE_MODE_CRASH MSG_NEWLINE); - serial_write(MSG_SAFE_MODE_FILE_ISSUE MSG_NEWLINE); - serial_write(MSG_SAFE_MODE_ISSUE_LINK MSG_NEWLINE); + serial_write(translate("Looks like our core CircuitPython code crashed hard. Whoops!\n")); + serial_write(translate("Please file an issue here with the contents of your CIRCUITPY drive:\n")); + serial_write("https://github.com/adafruit/circuitpython/issues\n"); } else if (safe_mode == BROWNOUT) { - serial_write(MSG_SAFE_MODE_BROWN_OUT_LINE_1 MSG_NEWLINE); - serial_write(MSG_SAFE_MODE_BROWN_OUT_LINE_2 MSG_NEWLINE); + serial_write(translate("The microcontroller's power dipped. Please make sure your power supply provides\n")); + serial_write(translate("enough power for the whole circuit and press reset (after ejecting CIRCUITPY).\n")); } } - serial_write(MSG_NEWLINE MSG_WAIT_BEFORE_REPL MSG_NEWLINE); + serial_write("\n"); + serial_write(translate("Press any key to enter the REPL. Use CTRL-D to reload.")); } if (serial_connected_before_animation && !serial_connected()) { serial_connected_at_start = false; @@ -400,7 +403,7 @@ int __attribute__((used)) main(void) { } if (exit_code == PYEXEC_FORCED_EXIT) { if (!first_run) { - serial_write(MSG_SOFT_REBOOT MSG_NEWLINE); + serial_write(translate("soft reboot\n")); } first_run = false; skip_repl = run_code_py(safe_mode); diff --git a/mpy-cross/Makefile b/mpy-cross/Makefile index c9b6cca0f3..d9234ac020 100644 --- a/mpy-cross/Makefile +++ b/mpy-cross/Makefile @@ -78,6 +78,7 @@ endif SRC_C = \ main.c \ gccollect.c \ + supervisor/shared/translate.c # Add fmode when compiling with mingw gcc COMPILER_TARGET := $(shell $(CC) -dumpmachine) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 7713a86482..37bae87f45 100755 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -439,20 +439,21 @@ $(BUILD)/firmware.elf: $(OBJ) $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE) $(BUILD)/firmware.bin: $(BUILD)/firmware.elf - $(ECHO) "Create $@" + $(STEPECHO) "Create $@" $(Q)$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@ $(BUILD)/firmware.uf2: $(BUILD)/firmware.bin - $(ECHO) "Create $@" - $(PYTHON2) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -c -o $@ $^ + $(STEPECHO) "Create $@" + $(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -c -o $@ $^ $(BUILD)/autogen_usb_descriptor.c $(BUILD)/genhdr/autogen_usb_descriptor.h: autogen_usb_descriptor.intermediate .INTERMEDIATE: autogen_usb_descriptor.intermediate -autogen_usb_descriptor.intermediate: tools/gen_usb_descriptor.py Makefile - install -d $(BUILD)/genhdr - $(PYTHON3) tools/gen_usb_descriptor.py \ +autogen_usb_descriptor.intermediate: tools/gen_usb_descriptor.py Makefile | $(HEADER_BUILD) + $(STEPECHO) "GEN $@" + $(Q)install -d $(BUILD)/genhdr + $(Q)$(PYTHON3) tools/gen_usb_descriptor.py \ --manufacturer $(USB_MANUFACTURER)\ --product $(USB_PRODUCT)\ --vid $(USB_VID)\ diff --git a/ports/atmel-samd/common-hal/analogio/AnalogIn.c b/ports/atmel-samd/common-hal/analogio/AnalogIn.c index d98e67f030..65ff383628 100644 --- a/ports/atmel-samd/common-hal/analogio/AnalogIn.c +++ b/ports/atmel-samd/common-hal/analogio/AnalogIn.c @@ -36,6 +36,7 @@ #include "samd/adc.h" #include "shared-bindings/analogio/AnalogIn.h" +#include "supervisor/shared/translate.h" #include "atmel_start_pins.h" #include "hal/include/hal_adc_sync.h" @@ -59,7 +60,7 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t* self, } if (adc_channel == 0xff) { // No ADC function on that pin - mp_raise_ValueError("Pin does not have ADC capabilities"); + mp_raise_ValueError(translate("Pin does not have ADC capabilities")); } claim_pin(pin); diff --git a/ports/atmel-samd/common-hal/analogio/AnalogOut.c b/ports/atmel-samd/common-hal/analogio/AnalogOut.c index 8c05b225e2..7eb8a7d480 100644 --- a/ports/atmel-samd/common-hal/analogio/AnalogOut.c +++ b/ports/atmel-samd/common-hal/analogio/AnalogOut.c @@ -32,6 +32,7 @@ #include "shared-bindings/analogio/AnalogOut.h" #include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/shared/translate.h" #include "atmel_start_pins.h" #include "hal/include/hal_dac_sync.h" @@ -49,7 +50,7 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self, && pin->number != PIN_PA05 #endif ) { - mp_raise_ValueError("AnalogOut not supported on given pin"); + mp_raise_ValueError(translate("AnalogOut not supported on given pin")); return; } diff --git a/ports/atmel-samd/common-hal/audiobusio/I2SOut.c b/ports/atmel-samd/common-hal/audiobusio/I2SOut.c index e8d26953c6..ab3091c3a3 100644 --- a/ports/atmel-samd/common-hal/audiobusio/I2SOut.c +++ b/ports/atmel-samd/common-hal/audiobusio/I2SOut.c @@ -35,6 +35,7 @@ #include "shared-bindings/audiobusio/I2SOut.h" #include "shared-bindings/audioio/RawSample.h" #include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/shared/translate.h" #include "atmel_start_pins.h" #include "hal/include/hal_gpio.h" @@ -143,16 +144,16 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t* self, } #endif if (bc_clock_unit == 0xff) { - mp_raise_ValueError("Invalid bit clock pin"); + mp_raise_ValueError(translate("Invalid bit clock pin")); } if (ws_clock_unit == 0xff) { - mp_raise_ValueError("Invalid bit clock pin"); + mp_raise_ValueError(translate("Invalid bit clock pin")); } if (bc_clock_unit != ws_clock_unit) { - mp_raise_ValueError("Bit clock and word select must share a clock unit"); + mp_raise_ValueError(translate("Bit clock and word select must share a clock unit")); } if (serializer == 0xff) { - mp_raise_ValueError("Invalid data pin"); + mp_raise_ValueError(translate("Invalid data pin")); } self->clock_unit = ws_clock_unit; self->serializer = serializer; @@ -165,12 +166,12 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t* self, } else { #ifdef SAMD21 if ((I2S->CTRLA.vec.SEREN & (1 << serializer)) != 0) { - mp_raise_RuntimeError("Serializer in use"); + mp_raise_RuntimeError(translate("Serializer in use")); } #endif #ifdef SAMD51 if (I2S->CTRLA.bit.TXEN == 1) { - mp_raise_RuntimeError("Serializer in use"); + mp_raise_RuntimeError(translate("Serializer in use")); } #endif } @@ -226,7 +227,7 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self, } #ifdef SAMD21 if ((I2S->CTRLA.vec.CKEN & (1 << self->clock_unit)) == 1) { - mp_raise_RuntimeError("Clock unit in use"); + mp_raise_RuntimeError(translate("Clock unit in use")); } #endif uint8_t bits_per_sample = audiosample_bits_per_sample(sample); @@ -236,7 +237,7 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self, // Find a free GCLK to generate the MCLK signal. uint8_t gclk = find_free_gclk(divisor); if (gclk > GCLK_GEN_NUM) { - mp_raise_RuntimeError("Unable to find free GCLK"); + mp_raise_RuntimeError(translate("Unable to find free GCLK")); } self->gclk = gclk; @@ -250,7 +251,7 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self, } uint8_t channel_count = audiosample_channel_count(sample); if (channel_count > 2) { - mp_raise_ValueError("Too many channels in sample."); + mp_raise_ValueError(translate("Too many channels in sample.")); } #ifdef SAMD21 uint32_t serctrl = (self->clock_unit << I2S_SERCTRL_CLKSEL_Pos) | SERCTRL(SERMODE_TX) | I2S_SERCTRL_TXSAME_SAME | I2S_SERCTRL_EXTEND_MSBIT | I2S_SERCTRL_TXDEFAULT_ONE | I2S_SERCTRL_SLOTADJ_LEFT; @@ -301,10 +302,10 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self, if (result == AUDIO_DMA_DMA_BUSY) { common_hal_audiobusio_i2sout_stop(self); - mp_raise_RuntimeError("No DMA channel found"); + mp_raise_RuntimeError(translate("No DMA channel found")); } else if (result == AUDIO_DMA_MEMORY_ERROR) { common_hal_audiobusio_i2sout_stop(self); - mp_raise_RuntimeError("Unable to allocate buffers for signed conversion"); + mp_raise_RuntimeError(translate("Unable to allocate buffers for signed conversion")); } I2S->INTFLAG.reg = I2S_INTFLAG_TXUR0 | I2S_INTFLAG_TXUR1; diff --git a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c index 3505eba8d5..90fbeb9e80 100644 --- a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c +++ b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -36,6 +36,7 @@ #include "shared-bindings/analogio/AnalogOut.h" #include "shared-bindings/audiobusio/PDMIn.h" #include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/shared/translate.h" #include "atmel_start_pins.h" #include "hal/include/hal_gpio.h" @@ -105,7 +106,7 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self, self->clock_unit = 1; #endif } else { - mp_raise_ValueError("Invalid clock pin"); + mp_raise_ValueError(translate("Invalid clock pin")); } self->data_pin = data_pin; // PA07, PA19 -> SD0, PA08, PB16 -> SD1 @@ -126,11 +127,11 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self, self->serializer = 1; #endif } else { - mp_raise_ValueError("Invalid data pin"); + mp_raise_ValueError(translate("Invalid data pin")); } if (!(bit_depth == 16 || bit_depth == 8) || !mono || oversample != OVERSAMPLING) { - mp_raise_NotImplementedError("Only 8 or 16 bit mono with " MP_STRINGIFY(OVERSAMPLING) "x oversampling is supported."); + mp_raise_NotImplementedError(translate("Only 8 or 16 bit mono with " MP_STRINGIFY(OVERSAMPLING) "x oversampling is supported.")); } turn_on_i2s(); @@ -141,12 +142,12 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self, } else { #ifdef SAMD21 if ((I2S->CTRLA.vec.SEREN & (1 << self->serializer)) != 0) { - mp_raise_RuntimeError("Serializer in use"); + mp_raise_RuntimeError(translate("Serializer in use")); } #endif #ifdef SAMD51 if (I2S->CTRLA.bit.RXEN == 1) { - mp_raise_RuntimeError("Serializer in use"); + mp_raise_RuntimeError(translate("Serializer in use")); } #endif } @@ -163,12 +164,12 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self, float mic_clock_freq = 48000000.0f / clock_divisor; self->sample_rate = mic_clock_freq / oversample; if (mic_clock_freq < MIN_MIC_CLOCK || clock_divisor == 0) { - mp_raise_ValueError("sampling rate out of range"); + mp_raise_ValueError(translate("sampling rate out of range")); } // Find a free GCLK to generate the MCLK signal. uint8_t gclk = find_free_gclk(clock_divisor); if (gclk > GCLK_GEN_NUM) { - mp_raise_RuntimeError("Unable to find free GCLK"); + mp_raise_RuntimeError(translate("Unable to find free GCLK")); } self->gclk = gclk; diff --git a/ports/atmel-samd/common-hal/audioio/AudioOut.c b/ports/atmel-samd/common-hal/audioio/AudioOut.c index 188053cad7..bef19b2cc2 100644 --- a/ports/atmel-samd/common-hal/audioio/AudioOut.c +++ b/ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -34,6 +34,7 @@ #include "common-hal/audioio/AudioOut.h" #include "shared-bindings/audioio/AudioOut.h" #include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/shared/translate.h" #include "atmel_start_pins.h" #include "hal/include/hal_gpio.h" @@ -65,14 +66,14 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self, #endif // Only support exclusive use of the DAC. if (dac_clock_enabled && DAC->CTRLA.bit.ENABLE == 1) { - mp_raise_RuntimeError("DAC already in use"); + mp_raise_RuntimeError(translate("DAC already in use")); } #ifdef SAMD21 if (right_channel != NULL) { - mp_raise_ValueError("Right channel unsupported"); + mp_raise_ValueError(translate("Right channel unsupported")); } if (left_channel != &pin_PA02) { - mp_raise_ValueError("Invalid pin"); + mp_raise_ValueError(translate("Invalid pin")); } assert_pin_free(left_channel); claim_pin(left_channel); @@ -80,14 +81,14 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self, #ifdef SAMD51 self->right_channel = NULL; if (left_channel != &pin_PA02 && left_channel != &pin_PA05) { - mp_raise_ValueError("Invalid pin for left channel"); + mp_raise_ValueError(translate("Invalid pin for left channel")); } assert_pin_free(left_channel); if (right_channel != NULL && right_channel != &pin_PA02 && right_channel != &pin_PA05) { - mp_raise_ValueError("Invalid pin for right channel"); + mp_raise_ValueError(translate("Invalid pin for right channel")); } if (right_channel == left_channel) { - mp_raise_ValueError("Cannot output both channels on the same pin"); + mp_raise_ValueError(translate("Cannot output both channels on the same pin")); } claim_pin(left_channel); if (right_channel != NULL) { @@ -169,7 +170,7 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self, } if (t == NULL) { common_hal_audioio_audioout_deinit(self); - mp_raise_RuntimeError("All timers in use"); + mp_raise_RuntimeError(translate("All timers in use")); return; } self->tc_index = tc_index; @@ -318,9 +319,9 @@ void common_hal_audioio_audioout_play(audioio_audioout_obj_t* self, audio_dma_stop(&self->right_dma); #endif if (result == AUDIO_DMA_DMA_BUSY) { - mp_raise_RuntimeError("No DMA channel found"); + mp_raise_RuntimeError(translate("No DMA channel found")); } else if (result == AUDIO_DMA_MEMORY_ERROR) { - mp_raise_RuntimeError("Unable to allocate buffers for signed conversion"); + mp_raise_RuntimeError(translate("Unable to allocate buffers for signed conversion")); } } Tc* timer = tc_insts[self->tc_index]; diff --git a/ports/atmel-samd/common-hal/busio/I2C.c b/ports/atmel-samd/common-hal/busio/I2C.c index 1119647a46..8bfa8ddd28 100644 --- a/ports/atmel-samd/common-hal/busio/I2C.c +++ b/ports/atmel-samd/common-hal/busio/I2C.c @@ -34,7 +34,7 @@ #include "samd/sercom.h" #include "shared-bindings/microcontroller/__init__.h" - +#include "supervisor/shared/translate.h" // Number of times to try to send packet if failed. #define ATTEMPTS 2 @@ -42,7 +42,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t* scl, const mcu_pin_obj_t* sda, uint32_t frequency, uint32_t timeout) { #ifdef PIRKEY_M0 - mp_raise_NotImplementedError("Not enough pins available"); + mp_raise_NotImplementedError(translate("Not enough pins available")); return; #endif Sercom* sercom = NULL; @@ -73,7 +73,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, } } if (sercom == NULL) { - mp_raise_ValueError("Invalid pins"); + mp_raise_ValueError(translate("Invalid pins")); } // Test that the pins are in a high state. (Hopefully indicating they are pulled up.) @@ -96,7 +96,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, if (!gpio_get_pin_level(sda->number) || !gpio_get_pin_level(scl->number)) { reset_pin(sda->number); reset_pin(scl->number); - mp_raise_RuntimeError("SDA or SCL needs a pull up"); + mp_raise_RuntimeError(translate("SDA or SCL needs a pull up")); } gpio_set_pin_function(sda->number, sda_pinmux); gpio_set_pin_function(scl->number, scl_pinmux); @@ -116,7 +116,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, if (i2c_m_sync_set_baudrate(&self->i2c_desc, 0, frequency / 1000) != ERR_NONE) { reset_pin(sda->number); reset_pin(scl->number); - mp_raise_ValueError("Unsupported baudrate"); + mp_raise_ValueError(translate("Unsupported baudrate")); } self->sda_pin = sda->number; diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index ecd5e1d2c6..1be245b4b6 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -32,6 +32,7 @@ #include "py/mperrno.h" #include "py/runtime.h" #include "py/stream.h" +#include "supervisor/shared/translate.h" #include "tick.h" @@ -62,13 +63,13 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, uint8_t tx_pad = 255; // Unset pad if (bits > 8) { - mp_raise_NotImplementedError("bytes > 8 bits not supported"); + mp_raise_NotImplementedError(translate("bytes > 8 bits not supported")); } bool have_tx = tx != mp_const_none; bool have_rx = rx != mp_const_none; if (!have_tx && !have_rx) { - mp_raise_ValueError("tx and rx cannot both be None"); + mp_raise_ValueError(translate("tx and rx cannot both be None")); } self->baudrate = baudrate; @@ -115,7 +116,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, } } if (sercom == NULL) { - mp_raise_ValueError("Invalid pins"); + mp_raise_ValueError(translate("Invalid pins")); } if (!have_tx) { tx_pad = 0; @@ -135,7 +136,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, self->buffer = (uint8_t *) gc_alloc(self->buffer_length * sizeof(uint8_t), false, false); if (self->buffer == NULL) { common_hal_busio_uart_deinit(self); - mp_raise_msg(&mp_type_MemoryError, "Failed to allocate RX buffer"); + mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate RX buffer")); } } else { self->buffer_length = 0; @@ -143,7 +144,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, } if (usart_async_init(usart_desc_p, sercom, self->buffer, self->buffer_length, NULL) != ERR_NONE) { - mp_raise_ValueError("Could not initialize UART"); + mp_raise_ValueError(translate("Could not initialize UART")); } // usart_async_init() sets a number of defaults based on a prototypical SERCOM @@ -230,7 +231,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { if (self->rx_pin == NO_PIN) { - mp_raise_ValueError("No RX pin"); + mp_raise_ValueError(translate("No RX pin")); } // This assignment is only here because the usart_async routines take a *const argument. @@ -280,7 +281,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if (self->tx_pin == NO_PIN) { - mp_raise_ValueError("No TX pin"); + mp_raise_ValueError(translate("No TX pin")); } // This assignment is only here because the usart_async routines take a *const argument. diff --git a/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c b/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c index 1dc7dce55c..7a48ef195e 100644 --- a/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +++ b/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c @@ -34,6 +34,7 @@ #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/digitalio/DigitalInOut.h" +#include "supervisor/shared/translate.h" digitalinout_result_t common_hal_digitalio_digitalinout_construct( digitalio_digitalinout_obj_t* self, const mcu_pin_obj_t* pin) { @@ -164,7 +165,7 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull( digitalio_digitalinout_obj_t* self) { uint32_t pin = self->pin->number; if (self->output) { - mp_raise_AttributeError("Cannot get pull while in output mode"); + mp_raise_AttributeError(translate("Cannot get pull while in output mode")); return PULL_NONE; } else { if (hri_port_get_PINCFG_PULLEN_bit(PORT, GPIO_PORT(pin), GPIO_PIN(pin)) == 0) { diff --git a/ports/atmel-samd/common-hal/microcontroller/__init__.c b/ports/atmel-samd/common-hal/microcontroller/__init__.c index ad4d81ddd0..efd2480243 100644 --- a/ports/atmel-samd/common-hal/microcontroller/__init__.c +++ b/ports/atmel-samd/common-hal/microcontroller/__init__.c @@ -35,6 +35,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Processor.h" +#include "supervisor/shared/translate.h" void common_hal_mcu_delay_us(uint32_t delay) { mp_hal_delay_us(delay); @@ -70,7 +71,7 @@ void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) { if (runmode == RUNMODE_BOOTLOADER) { if (!bootloader_available()) { - mp_raise_ValueError("Cannot reset into bootloader because no bootloader is present."); + mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present.")); } // Pretend to be the first of the two reset presses needed to enter the // bootloader. That way one reset will end in the bootloader. diff --git a/ports/atmel-samd/common-hal/pulseio/PWMOut.c b/ports/atmel-samd/common-hal/pulseio/PWMOut.c index 40281e2d87..4e1b61d787 100644 --- a/ports/atmel-samd/common-hal/pulseio/PWMOut.c +++ b/ports/atmel-samd/common-hal/pulseio/PWMOut.c @@ -35,6 +35,7 @@ #include "atmel_start_pins.h" #include "hal/utils/include/utils_repeat_macro.h" #include "samd/timers.h" +#include "supervisor/shared/translate.h" #include "samd/pins.h" @@ -112,11 +113,11 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, && pin->timer[2].index >= TCC_INST_NUM #endif ) { - mp_raise_ValueError("Invalid pin"); + mp_raise_ValueError(translate("Invalid pin")); } if (frequency == 0 || frequency > 6000000) { - mp_raise_ValueError("Invalid PWM frequency"); + mp_raise_ValueError(translate("Invalid PWM frequency")); } // Figure out which timer we are using. @@ -180,9 +181,9 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, if (timer == NULL) { if (found) { - mp_raise_ValueError("All timers for this pin are in use"); + mp_raise_ValueError(translate("All timers for this pin are in use")); } else { - mp_raise_RuntimeError("All timers in use"); + mp_raise_RuntimeError(translate("All timers in use")); } return; } @@ -362,7 +363,7 @@ uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) { void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) { if (frequency == 0 || frequency > 6000000) { - mp_raise_ValueError("Invalid PWM frequency"); + mp_raise_ValueError(translate("Invalid PWM frequency")); } const pin_timer_t* t = self->timer; uint8_t resolution; diff --git a/ports/atmel-samd/common-hal/pulseio/PulseIn.c b/ports/atmel-samd/common-hal/pulseio/PulseIn.c index 67a12f136d..3313073c5a 100644 --- a/ports/atmel-samd/common-hal/pulseio/PulseIn.c +++ b/ports/atmel-samd/common-hal/pulseio/PulseIn.c @@ -39,6 +39,7 @@ #include "samd/pins.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/pulseio/PulseIn.h" +#include "supervisor/shared/translate.h" #include "tick.h" @@ -106,15 +107,15 @@ void pulsein_interrupt_handler(uint8_t channel) { void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu_pin_obj_t* pin, uint16_t maxlen, bool idle_state) { if (!pin->has_extint) { - mp_raise_RuntimeError("No hardware support on pin"); + mp_raise_RuntimeError(translate("No hardware support on pin")); } if (eic_get_enable() && !eic_channel_free(pin->extint_channel)) { - mp_raise_RuntimeError("EXTINT channel already in use"); + mp_raise_RuntimeError(translate("EXTINT channel already in use")); } self->buffer = (uint16_t *) m_malloc(maxlen * sizeof(uint16_t), false); if (self->buffer == NULL) { - mp_raise_msg_varg(&mp_type_MemoryError, "Failed to allocate RX buffer of %d bytes", maxlen * sizeof(uint16_t)); + mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), maxlen * sizeof(uint16_t)); } self->channel = pin->extint_channel; self->pin = pin->number; @@ -199,7 +200,7 @@ void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t* self) { uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t* self) { if (self->len == 0) { - mp_raise_IndexError("pop from an empty PulseIn"); + mp_raise_IndexError(translate("pop from an empty PulseIn")); } common_hal_mcu_disable_interrupts(); uint16_t value = self->buffer[self->start]; @@ -231,7 +232,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, } if (index < 0 || index >= self->len) { common_hal_mcu_enable_interrupts(); - mp_raise_IndexError("index out of range"); + mp_raise_IndexError(translate("index out of range")); } uint16_t value = self->buffer[(self->start + index) % self->maxlen]; common_hal_mcu_enable_interrupts(); diff --git a/ports/atmel-samd/common-hal/pulseio/PulseOut.c b/ports/atmel-samd/common-hal/pulseio/PulseOut.c index 22280fbb30..8c9f28eb84 100644 --- a/ports/atmel-samd/common-hal/pulseio/PulseOut.c +++ b/ports/atmel-samd/common-hal/pulseio/PulseOut.c @@ -36,6 +36,7 @@ #include "py/gc.h" #include "py/runtime.h" #include "shared-bindings/pulseio/PulseOut.h" +#include "supervisor/shared/translate.h" // This timer is shared amongst all PulseOut objects under the assumption that // the code is single threaded. @@ -106,7 +107,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self, } } if (tc == NULL) { - mp_raise_RuntimeError("All timers in use"); + mp_raise_RuntimeError(translate("All timers in use")); } pulseout_tc_index = index; @@ -174,7 +175,7 @@ void common_hal_pulseio_pulseout_deinit(pulseio_pulseout_obj_t* self) { void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t* self, uint16_t* pulses, uint16_t length) { if (active_pincfg != NULL) { - mp_raise_RuntimeError("Another send is already active"); + mp_raise_RuntimeError(translate("Another send is already active")); } active_pincfg = self->pincfg; pulse_buffer = pulses; diff --git a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c index f2817d5d7c..c1ceb410f7 100644 --- a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -30,11 +30,12 @@ #include "samd/external_interrupts.h" #include "py/runtime.h" +#include "supervisor/shared/translate.h" void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencoder_obj_t* self, const mcu_pin_obj_t* pin_a, const mcu_pin_obj_t* pin_b) { if (!pin_a->has_extint || !pin_a->has_extint) { - mp_raise_RuntimeError("Both pins must support hardware interrupts"); + mp_raise_RuntimeError(translate("Both pins must support hardware interrupts")); } // TODO: The SAMD51 has a peripheral dedicated to quadrature encoder debugging. Use it instead @@ -42,7 +43,7 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode if (eic_get_enable()) { if (!eic_channel_free(pin_a->extint_channel) || !eic_channel_free(pin_b->extint_channel)) { - mp_raise_RuntimeError("A hardware interrupt channel is already in use"); + mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use")); } } else { turn_on_external_interrupt_controller(); diff --git a/ports/atmel-samd/common-hal/rtc/RTC.c b/ports/atmel-samd/common-hal/rtc/RTC.c index 680a88deb5..4c888418b6 100644 --- a/ports/atmel-samd/common-hal/rtc/RTC.c +++ b/ports/atmel-samd/common-hal/rtc/RTC.c @@ -36,6 +36,7 @@ #include "py/runtime.h" #include "lib/timeutils/timeutils.h" #include "shared-bindings/rtc/__init__.h" +#include "supervisor/shared/translate.h" static struct calendar_descriptor calendar; @@ -97,7 +98,7 @@ int common_hal_rtc_get_calibration(void) { void common_hal_rtc_set_calibration(int calibration) { if (calibration > 127 || calibration < -127) - mp_raise_ValueError("calibration value out of range +/-127"); + mp_raise_ValueError(translate("calibration value out of range +/-127")); hri_rtcmode0_write_FREQCORR_SIGN_bit(calendar.device.hw, calibration < 0 ? 0 : 1); hri_rtcmode0_write_FREQCORR_VALUE_bf(calendar.device.hw, abs(calibration)); diff --git a/ports/atmel-samd/common-hal/storage/__init__.c b/ports/atmel-samd/common-hal/storage/__init__.c index 3838655588..501a19dd79 100644 --- a/ports/atmel-samd/common-hal/storage/__init__.c +++ b/ports/atmel-samd/common-hal/storage/__init__.c @@ -32,6 +32,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/storage/__init__.h" #include "supervisor/filesystem.h" +#include "supervisor/shared/translate.h" #include "usb.h" extern volatile bool mp_msc_enabled; @@ -44,7 +45,7 @@ void common_hal_storage_remount(const char* mount_path, bool readonly) { // TODO(dhalbert): is this is a good enough check? It checks for // CDC enabled. There is no "MSC enabled" check. if (usb_connected()) { - mp_raise_RuntimeError("Cannot remount '/' when USB is active."); + mp_raise_RuntimeError(translate("Cannot remount '/' when USB is active.")); } flash_set_usb_writable(readonly); diff --git a/ports/atmel-samd/common-hal/touchio/TouchIn.c b/ports/atmel-samd/common-hal/touchio/TouchIn.c index 382f95c85e..7fa61d3dd4 100644 --- a/ports/atmel-samd/common-hal/touchio/TouchIn.c +++ b/ports/atmel-samd/common-hal/touchio/TouchIn.c @@ -32,6 +32,7 @@ #include "py/binary.h" #include "py/mphal.h" #include "shared-bindings/touchio/TouchIn.h" +#include "supervisor/shared/translate.h" #ifdef SAMD21 #include "hpl/pm/hpl_pm_base.h" @@ -61,7 +62,7 @@ static uint16_t get_raw_reading(touchio_touchin_obj_t *self) { void common_hal_touchio_touchin_construct(touchio_touchin_obj_t* self, const mcu_pin_obj_t *pin) { if (!pin->has_touch) { - mp_raise_ValueError("Invalid pin"); + mp_raise_ValueError(translate("Invalid pin")); } claim_pin(pin); @@ -71,7 +72,7 @@ void common_hal_touchio_touchin_construct(touchio_touchin_obj_t* self, // We run the PTC at 8mhz so divide the 48mhz clock by 6. uint8_t gclk = find_free_gclk(6); if (gclk > GCLK_GEN_NUM) { - mp_raise_RuntimeError("No free GCLKs"); + mp_raise_RuntimeError(translate("No free GCLKs")); } enable_clock_generator(gclk, CLOCK_48MHZ, 6); diff --git a/ports/atmel-samd/common-hal/usb_hid/Device.c b/ports/atmel-samd/common-hal/usb_hid/Device.c index ae6985aa9c..31bace0189 100644 --- a/ports/atmel-samd/common-hal/usb_hid/Device.c +++ b/ports/atmel-samd/common-hal/usb_hid/Device.c @@ -31,6 +31,7 @@ #include "py/runtime.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/usb_hid/Device.h" +#include "supervisor/shared/translate.h" #include "genhdr/autogen_usb_descriptor.h" #include "tick.h" @@ -74,11 +75,11 @@ static uint32_t usb_hid_send_report(usb_hid_device_obj_t *self, uint8_t* report, void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t* report, uint8_t len) { if (len != self->report_length) { - mp_raise_ValueError_varg("Buffer incorrect size. Should be %d bytes.", self->report_length); + mp_raise_ValueError_varg(translate("Buffer incorrect size. Should be %d bytes."), self->report_length); } int32_t status = usb_hid_send_report(self, report, len); if (status != ERR_NONE) { - mp_raise_msg(&mp_type_OSError, status == USB_BUSY ? "USB Busy" : "USB Error"); + mp_raise_msg(&mp_type_OSError, status == USB_BUSY ? translate("USB Busy") : translate("USB Error")); } } diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile index 89e9be0c3a..3a99b405cd 100644 --- a/ports/esp8266/Makefile +++ b/ports/esp8266/Makefile @@ -97,6 +97,7 @@ SRC_C = \ posix_helpers.c \ hspi.c \ boards/$(BOARD)/pins.c \ + supervisor/shared/translate.c \ $(SRC_MOD) SRC_COMMON_HAL = \ diff --git a/ports/unix/Makefile b/ports/unix/Makefile index 104ad3e5d1..1c112e0b22 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -149,6 +149,7 @@ SRC_C = \ alloc.c \ coverage.c \ fatfs_port.c \ + supervisor/shared/translate.c \ $(SRC_MOD) LIB_SRC_C = $(addprefix lib/,\ diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py index 3c0a609092..719bc62faf 100644 --- a/py/makeqstrdata.py +++ b/py/makeqstrdata.py @@ -9,6 +9,9 @@ from __future__ import print_function import re import sys +import collections +import gettext + # Python 2/3 compatibility: # - iterating through bytes is different # - codepoint2name lives in a different module @@ -59,6 +62,12 @@ def compute_hash(qstr, bytes_hash): # Make sure that valid hash is never zero, zero means "hash not computed" return (hash & ((1 << (8 * bytes_hash)) - 1)) or 1 +def translate(translation_file, i18ns): + with open(translation_file, "rb") as f: + table = gettext.GNUTranslations(f) + + return [(x, table.gettext(x)) for x in i18ns] + def qstr_escape(qst): def esc_char(m): c = ord(m.group(0)) @@ -73,6 +82,7 @@ def parse_input_headers(infiles): # read the qstrs in from the input files qcfgs = {} qstrs = {} + i18ns = set() for infile in infiles: with open(infile, 'rt') as f: for line in f: @@ -88,6 +98,12 @@ def parse_input_headers(infiles): qcfgs[match.group(1)] = value continue + + match = re.match(r'^TRANSLATE\("(.*)"\)$', line) + if match: + i18ns.add(match.group(1)) + continue + # is this a QSTR line? match = re.match(r'^Q\((.*)\)$', line) if not match: @@ -121,11 +137,11 @@ def parse_input_headers(infiles): order -= 100000 qstrs[ident] = (order, ident, qstr) - if not qcfgs: + if not qcfgs and qstrs: sys.stderr.write("ERROR: Empty preprocessor output - check for errors above\n") sys.exit(1) - return qcfgs, qstrs + return qcfgs, qstrs, i18ns def make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr): qbytes = bytes_cons(qstr, 'utf8') @@ -144,7 +160,7 @@ def make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr): qhash_str = ('\\x%02x' * cfg_bytes_hash) % tuple(((qhash >> (8 * i)) & 0xff) for i in range(cfg_bytes_hash)) return '(const byte*)"%s%s" "%s"' % (qhash_str, qlen_str, qdata) -def print_qstr_data(qcfgs, qstrs): +def print_qstr_data(qcfgs, qstrs, i18ns): # get config variables cfg_bytes_len = int(qcfgs['BYTES_IN_LEN']) cfg_bytes_hash = int(qcfgs['BYTES_IN_HASH']) @@ -156,14 +172,48 @@ def print_qstr_data(qcfgs, qstrs): # add NULL qstr with no hash or data print('QDEF(MP_QSTR_NULL, (const byte*)"%s%s" "")' % ('\\x00' * cfg_bytes_hash, '\\x00' * cfg_bytes_len)) + total_qstr_size = 0 # go through each qstr and print it out for order, ident, qstr in sorted(qstrs.values(), key=lambda x: x[0]): qbytes = make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr) print('QDEF(MP_QSTR_%s, %s)' % (ident, qbytes)) + total_qstr_size += len(qstr) -def do_work(infiles): - qcfgs, qstrs = parse_input_headers(infiles) - print_qstr_data(qcfgs, qstrs) + total_text_size = 0 + for original, translation in i18ns: + print("TRANSLATION(\"{}\", \"{}\")".format(original, translation)) + total_text_size += len(translation) + + print() + print("// {} bytes worth of qstr".format(total_qstr_size)) + print("// {} bytes worth of translations".format(total_text_size)) + +def print_qstr_enums(qstrs): + # print out the starter of the generated C header file + print('// This file was automatically generated by makeqstrdata.py') + print('') + + # add NULL qstr with no hash or data + print('QENUM(MP_QSTR_NULL)') + + # go through each qstr and print it out + for order, ident, qstr in sorted(qstrs.values(), key=lambda x: x[0]): + print('QENUM(MP_QSTR_%s)' % (ident,)) if __name__ == "__main__": - do_work(sys.argv[1:]) + import argparse + + parser = argparse.ArgumentParser(description='Process QSTR definitions into headers for compilation') + parser.add_argument('infiles', metavar='N', type=str, nargs='+', + help='an integer for the accumulator') + parser.add_argument('--translation', default=None, type=str, + help='translations for i18n() items') + + args = parser.parse_args() + + qcfgs, qstrs, i18ns = parse_input_headers(args.infiles) + if args.translation: + translations = translate(args.translation, i18ns) + print_qstr_data(qcfgs, qstrs, translations) + else: + print_qstr_enums(qstrs) diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py index 4253c1147b..06cf9078a0 100644 --- a/py/makeqstrdefs.py +++ b/py/makeqstrdefs.py @@ -73,10 +73,11 @@ def qstr_unescape(qstr): return qstr def process_file(f): - re_line = re.compile(r"#[line]*\s\d+\s\"([^\"]+)\"") + re_line = re.compile(r"#[line]*\s(\d+)\s\"([^\"]+)\"") re_qstr = re.compile(r'MP_QSTR_[_a-zA-Z0-9]+') output = [] last_fname = None + lineno = 0 for line in f: if line.isspace(): continue @@ -84,7 +85,9 @@ def process_file(f): if line.startswith(('# ', '#line')): m = re_line.match(line) assert m is not None - fname = m.group(1) + #print(m.groups()) + lineno = int(m.group(1)) + fname = m.group(2) if not fname.endswith(".c"): continue if fname != last_fname: @@ -96,6 +99,9 @@ def process_file(f): name = match.replace('MP_QSTR_', '') if name not in QSTRING_BLACK_LIST: output.append('Q(' + qstr_unescape(name) + ')') + for match in re.findall(r'translate\(\"([^\"]+)\"\)', line): + output.append('TRANSLATE("' + match + '")') + lineno += 1 write_out(last_fname, output) return "" diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py index 89a604aebf..7ceeaeadde 100644 --- a/py/makeversionhdr.py +++ b/py/makeversionhdr.py @@ -100,7 +100,6 @@ def make_version_header(filename): # Only write the file if we need to if write_file: - print("GEN %s" % filename) with open(filename, 'w') as f: f.write(file_data) diff --git a/py/mkrules.mk b/py/mkrules.mk index 621d024a96..f1276f8046 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -71,22 +71,22 @@ $(BUILD)/%.pp: %.c # the right .o's to get recompiled if the generated.h file changes. Adding # an order-only dependency to all of the .o's will cause the generated .h # to get built before we try to compile any of them. -$(OBJ): | $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/mpversion.h +$(OBJ): | $(HEADER_BUILD)/qstrdefs.enum.h $(HEADER_BUILD)/mpversion.h # The logic for qstr regeneration is: # - if anything in QSTR_GLOBAL_DEPENDENCIES is newer, then process all source files ($^) # - else, if list of newer prerequisites ($?) is not empty, then process just these ($?) # - else, process all source files ($^) [this covers "make -B" which can set $? to empty] $(HEADER_BUILD)/qstr.i.last: $(SRC_QSTR) $(SRC_QSTR_PREPROCESSOR) $(QSTR_GLOBAL_DEPENDENCIES) | $(HEADER_BUILD)/mpversion.h - $(ECHO) "GEN $@" + $(STEPECHO) "GEN $@" $(Q)grep -lE "(MP_QSTR|i18n)" $(if $(filter $?,$(QSTR_GLOBAL_DEPENDENCIES)),$^,$(if $?,$?,$^)) | xargs $(CPP) $(QSTR_GEN_EXTRA_CFLAGS) $(CFLAGS) $(SRC_QSTR_PREPROCESSOR) >$(HEADER_BUILD)/qstr.i.last; -$(HEADER_BUILD)/qstr.split: $(HEADER_BUILD)/qstr.i.last +$(HEADER_BUILD)/qstr.split: $(HEADER_BUILD)/qstr.i.last $(PY_SRC)/makeqstrdefs.py $(STEPECHO) "GEN $@" $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py split $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED) $(Q)touch $@ -$(QSTR_DEFS_COLLECTED): $(HEADER_BUILD)/qstr.split +$(QSTR_DEFS_COLLECTED): $(HEADER_BUILD)/qstr.split $(PY_SRC)/makeqstrdefs.py $(STEPECHO) "GEN $@" $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py cat $(HEADER_BUILD)/qstr.i.last $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED) diff --git a/py/modbuiltins.c b/py/modbuiltins.c index eb1a172045..4b24e8811e 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -35,6 +35,8 @@ #include "py/builtin.h" #include "py/stream.h" +#include "supervisor/shared/translate.h" + #if MICROPY_PY_BUILTINS_FLOAT #include #endif @@ -157,7 +159,7 @@ STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) { str[3] = (c & 0x3F) | 0x80; len = 4; } else { - mp_raise_ValueError("chr() arg not in range(0x110000)"); + mp_raise_ValueError(translate("chr() arg not in range(0x110000)")); } return mp_obj_new_str_via_qstr((char*)str, len); #else @@ -166,7 +168,7 @@ STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) { uint8_t str[1] = {ord}; return mp_obj_new_str_via_qstr((char*)str, 1); } else { - mp_raise_ValueError("chr() arg not in range(256)"); + mp_raise_ValueError(translate("chr() arg not in range(256)")); } #endif } @@ -280,7 +282,7 @@ STATIC mp_obj_t mp_builtin_min_max(size_t n_args, const mp_obj_t *args, mp_map_t if (default_elem != NULL) { best_obj = default_elem->value; } else { - mp_raise_ValueError("arg is an empty sequence"); + mp_raise_ValueError(translate("arg is an empty sequence")); } } return best_obj; @@ -345,10 +347,10 @@ STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) { } if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { - mp_raise_TypeError("ord expects a character"); + mp_raise_TypeError(translate("ord expects a character")); } else { mp_raise_TypeError_varg( - "ord() expected a character, but string of length %d found", (int)len); + translate("ord() expected a character, but string of length %d found"), (int)len); } } MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord); @@ -358,7 +360,7 @@ STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) { case 2: return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]); default: #if !MICROPY_PY_BUILTINS_POW3 - mp_raise_msg(&mp_type_NotImplementedError, "3-arg pow() not supported"); + mp_raise_msg(&mp_type_NotImplementedError, translate("3-arg pow() not supported")); #elif MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_MPZ return mp_binary_op(MP_BINARY_OP_MODULO, mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]), args[2]); #else @@ -512,7 +514,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_sum_obj, 1, 2, mp_builtin_sum); STATIC mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) { if (n_args > 1) { - mp_raise_TypeError("must use keyword argument for key function"); + mp_raise_TypeError(translate("must use keyword argument for key function")); } mp_obj_t self = mp_type_list.make_new(&mp_type_list, 1, 0, args); mp_obj_list_sort(1, &self, kwargs); diff --git a/py/modstruct.c b/py/modstruct.c index 8617a8e0d3..3f1b2f8b8c 100644 --- a/py/modstruct.c +++ b/py/modstruct.c @@ -33,6 +33,7 @@ #include "py/objtuple.h" #include "py/binary.h" #include "py/parsenum.h" +#include "supervisor/shared/translate.h" #if MICROPY_PY_STRUCT @@ -141,7 +142,7 @@ STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) { // negative offsets are relative to the end of the buffer offset = bufinfo.len + offset; if (offset < 0) { - mp_raise_ValueError("buffer too small"); + mp_raise_ValueError(translate("buffer too small")); } } p += offset; @@ -149,7 +150,7 @@ STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) { // Check that the input buffer is big enough to unpack all the values if (p + total_sz > end_p) { - mp_raise_ValueError("buffer too small"); + mp_raise_ValueError(translate("buffer too small")); } for (size_t i = 0; i < num_items;) { @@ -230,7 +231,7 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) { // negative offsets are relative to the end of the buffer offset = (mp_int_t)bufinfo.len + offset; if (offset < 0) { - mp_raise_ValueError("buffer too small"); + mp_raise_ValueError(translate("buffer too small")); } } byte *p = (byte *)bufinfo.buf; @@ -240,7 +241,7 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) { // Check that the output buffer is big enough to hold all the values mp_int_t sz = MP_OBJ_SMALL_INT_VALUE(struct_calcsize(args[0])); if (p + sz > end_p) { - mp_raise_ValueError("buffer too small"); + mp_raise_ValueError(translate("buffer too small")); } struct_pack_into_internal(args[0], p, n_args - 3, &args[3]); diff --git a/py/py.mk b/py/py.mk index 8e1b86a13e..ecd66531b5 100644 --- a/py/py.mk +++ b/py/py.mk @@ -7,6 +7,8 @@ HEADER_BUILD = $(BUILD)/genhdr # file containing qstr defs for the core Python bit PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h +TRANSLATION := en_US + # If qstr autogeneration is not disabled we specify the output header # for all collected qstrings. ifneq ($(QSTR_AUTOGEN_DISABLE),1) @@ -288,21 +290,34 @@ FORCE: .PHONY: FORCE $(HEADER_BUILD)/mpversion.h: FORCE | $(HEADER_BUILD) + $(STEPECHO) "GEN $@" $(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $@ # mpconfigport.mk is optional, but changes to it may drastically change # overall config, so they need to be caught MPCONFIGPORT_MK = $(wildcard mpconfigport.mk) +$(HEADER_BUILD)/$(TRANSLATION).mo: $(TOP)/locale/$(TRANSLATION).po + $(Q)msgfmt -o $@ $^ + +$(HEADER_BUILD)/qstrdefs.preprocessed.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) mpconfigport.h $(MPCONFIGPORT_MK) $(PY_SRC)/mpconfig.h | $(HEADER_BUILD) + $(STEPECHO) "GEN $@" + $(Q)cat $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) | $(SED) 's/^Q(.*)/"&"/' | $(CPP) $(CFLAGS) - | $(SED) 's/^"\(Q(.*)\)"/\1/' > $@ + # qstr data +$(HEADER_BUILD)/qstrdefs.enum.h: $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h + $(STEPECHO) "GEN $@" + $(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@ + # Adding an order only dependency on $(HEADER_BUILD) causes $(HEADER_BUILD) to get # created before we run the script to generate the .h # Note: we need to protect the qstr names from the preprocessor, so we wrap # the lines in "" and then unwrap after the preprocessor is finished. -$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(MPCONFIGPORT_MK) $(PY_SRC)/mpconfig.h | $(HEADER_BUILD) - $(ECHO) "GEN $@" - $(Q)cat $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) | $(SED) 's/^Q(.*)/"&"/' | $(CPP) $(CFLAGS) - | $(SED) 's/^"\(Q(.*)\)"/\1/' > $(HEADER_BUILD)/qstrdefs.preprocessed.h - $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@ +$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/$(TRANSLATION).mo $(HEADER_BUILD)/qstrdefs.preprocessed.h + $(STEPECHO) "GEN $@" + $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py --translation $(HEADER_BUILD)/$(TRANSLATION).mo $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@ + +$(PY_BUILD)/qstr.o: $(HEADER_BUILD)/qstrdefs.generated.h # Force nlr code to always be compiled with space-saving optimisation so # that the function preludes are of a minimal and predictable form. diff --git a/py/qstr.c b/py/qstr.c index c68f3dfec6..90581664ce 100755 --- a/py/qstr.c +++ b/py/qstr.c @@ -104,7 +104,9 @@ const qstr_pool_t mp_qstr_const_pool = { { #ifndef NO_QSTR #define QDEF(id, str) str, +#define TRANSLATION(id, str) #include "genhdr/qstrdefs.generated.h" +#undef TRANSLATION #undef QDEF #endif }, diff --git a/py/qstr.h b/py/qstr.h index f4375ee0e9..39b904fb18 100644 --- a/py/qstr.h +++ b/py/qstr.h @@ -38,9 +38,9 @@ // first entry in enum will be MP_QSTR_NULL=0, which indicates invalid/no qstr enum { #ifndef NO_QSTR -#define QDEF(id, str) id, -#include "genhdr/qstrdefs.generated.h" -#undef QDEF +#define QENUM(id) id, +#include "genhdr/qstrdefs.enum.h" +#undef QENUM #endif MP_QSTRnumber_of, // no underscore so it can't clash with any of the above }; diff --git a/shared-bindings/_stage/Layer.c b/shared-bindings/_stage/Layer.c index 3e615c4977..a3334f635f 100644 --- a/shared-bindings/_stage/Layer.c +++ b/shared-bindings/_stage/Layer.c @@ -28,6 +28,7 @@ #include "__init__.h" #include "Layer.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: _stage //| @@ -67,20 +68,20 @@ STATIC mp_obj_t layer_make_new(const mp_obj_type_t *type, size_t n_args, mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ); self->graphic = bufinfo.buf; if (bufinfo.len != 2048) { - mp_raise_ValueError("graphic must be 2048 bytes long"); + mp_raise_ValueError(translate("graphic must be 2048 bytes long")); } mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_READ); self->palette = bufinfo.buf; if (bufinfo.len != 32) { - mp_raise_ValueError("palette must be 32 bytes long"); + mp_raise_ValueError(translate("palette must be 32 bytes long")); } if (n_args > 4) { mp_get_buffer_raise(args[4], &bufinfo, MP_BUFFER_READ); self->map = bufinfo.buf; if (bufinfo.len < (self->width * self->height) / 2) { - mp_raise_ValueError("map buffer too small"); + mp_raise_ValueError(translate("map buffer too small")); } } else { self-> map = NULL; diff --git a/shared-bindings/_stage/Text.c b/shared-bindings/_stage/Text.c index c62d22afee..7a406271df 100644 --- a/shared-bindings/_stage/Text.c +++ b/shared-bindings/_stage/Text.c @@ -28,6 +28,7 @@ #include "__init__.h" #include "Text.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: _stage //| @@ -65,19 +66,19 @@ STATIC mp_obj_t text_make_new(const mp_obj_type_t *type, size_t n_args, mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ); self->font = bufinfo.buf; if (bufinfo.len != 2048) { - mp_raise_ValueError("font must be 2048 bytes long"); + mp_raise_ValueError(translate("font must be 2048 bytes long")); } mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_READ); self->palette = bufinfo.buf; if (bufinfo.len != 32) { - mp_raise_ValueError("palette must be 32 bytes long"); + mp_raise_ValueError(translate("palette must be 32 bytes long")); } mp_get_buffer_raise(args[4], &bufinfo, MP_BUFFER_READ); self->chars = bufinfo.buf; if (bufinfo.len < self->width * self->height) { - mp_raise_ValueError("chars buffer too small"); + mp_raise_ValueError(translate("chars buffer too small")); } return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c index 721448fa4a..58ed5b6b2f 100644 --- a/shared-bindings/analogio/AnalogOut.c +++ b/shared-bindings/analogio/AnalogOut.c @@ -34,6 +34,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/analogio/AnalogOut.h" #include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: analogio //| @@ -114,7 +115,7 @@ STATIC mp_obj_t analogio_analogout_obj_set_value(mp_obj_t self_in, mp_obj_t valu raise_error_if_deinited(common_hal_analogio_analogout_deinited(self)); uint32_t v = mp_obj_get_int(value); if (v >= (1 << 16)) { - mp_raise_ValueError("AnalogOut is only 16 bits. Value must be less than 65536."); + mp_raise_ValueError(translate("AnalogOut is only 16 bits. Value must be less than 65536.")); } common_hal_analogio_analogout_set_value(self, v); return mp_const_none; diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index 4254c8ddbe..e3eef924d0 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -33,6 +33,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/audiobusio/I2SOut.h" #include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: audiobusio //| @@ -221,7 +222,7 @@ STATIC mp_obj_t audiobusio_i2sout_obj_pause(mp_obj_t self_in) { raise_error_if_deinited(common_hal_audiobusio_i2sout_deinited(self)); if (!common_hal_audiobusio_i2sout_get_playing(self)) { - mp_raise_RuntimeError("Not playing"); + mp_raise_RuntimeError(translate("Not playing")); } common_hal_audiobusio_i2sout_pause(self); return mp_const_none; diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index 9ddfc5f11f..831baea901 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -34,6 +34,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/audiobusio/PDMIn.h" #include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: audiobusio //| @@ -120,11 +121,11 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar uint32_t sample_rate = args[ARG_sample_rate].u_int; uint8_t bit_depth = args[ARG_bit_depth].u_int; if (bit_depth % 8 != 0) { - mp_raise_ValueError("Bit depth must be multiple of 8."); + mp_raise_ValueError(translate("Bit depth must be multiple of 8.")); } uint8_t oversample = args[ARG_oversample].u_int; if (oversample % 8 != 0) { - mp_raise_ValueError("Oversample must be multiple of 8."); + mp_raise_ValueError(translate("Oversample must be multiple of 8.")); } bool mono = args[ARG_mono].u_bool; @@ -132,7 +133,7 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar ? STARTUP_DELAY_DEFAULT : mp_obj_get_float(args[ARG_startup_delay].u_obj); if (startup_delay < 0.0 || startup_delay > 1.0) { - mp_raise_ValueError("Microphone startup delay must be in range 0.0 to 1.0"); + mp_raise_ValueError(translate("Microphone startup delay must be in range 0.0 to 1.0")); } common_hal_audiobusio_pdmin_construct(self, clock_pin, data_pin, sample_rate, @@ -189,7 +190,7 @@ STATIC mp_obj_t audiobusio_pdmin_obj_record(mp_obj_t self_obj, mp_obj_t destinat audiobusio_pdmin_obj_t *self = MP_OBJ_TO_PTR(self_obj); raise_error_if_deinited(common_hal_audiobusio_pdmin_deinited(self)); if (!MP_OBJ_IS_SMALL_INT(destination_length) || MP_OBJ_SMALL_INT_VALUE(destination_length) < 0) { - mp_raise_TypeError("destination_length must be an int >= 0"); + mp_raise_TypeError(translate("destination_length must be an int >= 0")); } uint32_t length = MP_OBJ_SMALL_INT_VALUE(destination_length); @@ -198,13 +199,13 @@ STATIC mp_obj_t audiobusio_pdmin_obj_record(mp_obj_t self_obj, mp_obj_t destinat mp_raise_NotImplementedError(""); } else if (mp_get_buffer(destination, &bufinfo, MP_BUFFER_WRITE)) { if (bufinfo.len / mp_binary_get_size('@', bufinfo.typecode, NULL) < length) { - mp_raise_ValueError("Destination capacity is smaller than destination_length."); + mp_raise_ValueError(translate("Destination capacity is smaller than destination_length.")); } uint8_t bit_depth = common_hal_audiobusio_pdmin_get_bit_depth(self); if (bufinfo.typecode != 'H' && bit_depth == 16) { - mp_raise_ValueError("destination buffer must be an array of type 'H' for bit_depth = 16"); + mp_raise_ValueError(translate("destination buffer must be an array of type 'H' for bit_depth = 16")); } else if (bufinfo.typecode != 'B' && bufinfo.typecode != BYTEARRAY_TYPECODE && bit_depth == 8) { - mp_raise_ValueError("destination buffer must be a bytearray or array of type 'B' for bit_depth = 8"); + mp_raise_ValueError(translate("destination buffer must be a bytearray or array of type 'B' for bit_depth = 8")); } // length is the buffer length in slots, not bytes. uint32_t length_written = diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 97fe2dce5b..db5b371e22 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -34,6 +34,7 @@ #include "shared-bindings/audioio/AudioOut.h" #include "shared-bindings/audioio/RawSample.h" #include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: audioio //| @@ -219,7 +220,7 @@ STATIC mp_obj_t audioio_audioout_obj_pause(mp_obj_t self_in) { raise_error_if_deinited(common_hal_audioio_audioout_deinited(self)); if (!common_hal_audioio_audioout_get_playing(self)) { - mp_raise_RuntimeError("Not playing"); + mp_raise_RuntimeError(translate("Not playing")); } common_hal_audioio_audioout_pause(self); return mp_const_none; diff --git a/shared-bindings/audioio/RawSample.c b/shared-bindings/audioio/RawSample.c index a66145931c..28b6027c3e 100644 --- a/shared-bindings/audioio/RawSample.c +++ b/shared-bindings/audioio/RawSample.c @@ -33,6 +33,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/audioio/AudioOut.h" #include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: audioio //| @@ -94,13 +95,13 @@ STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_a if (bufinfo.typecode == 'h' || bufinfo.typecode == 'H') { bytes_per_sample = 2; } else if (bufinfo.typecode != 'b' && bufinfo.typecode != 'B' && bufinfo.typecode != BYTEARRAY_TYPECODE) { - mp_raise_ValueError("sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or 'B'"); + mp_raise_ValueError(translate("sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or 'B'")); } common_hal_audioio_rawsample_construct(self, ((uint8_t*)bufinfo.buf), bufinfo.len, bytes_per_sample, signed_samples, args[ARG_channel_count].u_int, args[ARG_sample_rate].u_int); } else { - mp_raise_TypeError("buffer must be a bytes-like object"); + mp_raise_TypeError(translate("buffer must be a bytes-like object")); } return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/audioio/WaveFile.c b/shared-bindings/audioio/WaveFile.c index 05768e14d7..4ff0abddab 100644 --- a/shared-bindings/audioio/WaveFile.c +++ b/shared-bindings/audioio/WaveFile.c @@ -27,12 +27,11 @@ #include #include "lib/utils/context_manager_helpers.h" -// #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" -// #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/audioio/WaveFile.h" #include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: audioio //| @@ -76,7 +75,7 @@ STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_ar if (MP_OBJ_IS_TYPE(args[0], &mp_type_fileio)) { common_hal_audioio_wavefile_construct(self, MP_OBJ_TO_PTR(args[0])); } else { - mp_raise_TypeError("file must be a file opened in byte mode"); + mp_raise_TypeError(translate("file must be a file opened in byte mode")); } return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/bitbangio/I2C.c b/shared-bindings/bitbangio/I2C.c index a5c000ae5a..7f42153ec8 100644 --- a/shared-bindings/bitbangio/I2C.c +++ b/shared-bindings/bitbangio/I2C.c @@ -35,6 +35,7 @@ #include "lib/utils/context_manager_helpers.h" #include "py/mperrno.h" #include "py/runtime.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: bitbangio //| @@ -107,7 +108,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitbangio_i2c_obj___exit___obj, 4, 4, static void check_lock(bitbangio_i2c_obj_t *self) { if (!shared_module_bitbangio_i2c_has_lock(self)) { - mp_raise_RuntimeError("Function requires lock"); + mp_raise_RuntimeError(translate("Function requires lock")); } } @@ -191,7 +192,7 @@ STATIC mp_obj_t bitbangio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_a uint32_t length = bufinfo.len; normalize_buffer_bounds(&start, args[ARG_end].u_int, &length); if (length == 0) { - mp_raise_ValueError("Buffer must be at least length 1"); + mp_raise_ValueError(translate("Buffer must be at least length 1")); } uint8_t status = shared_module_bitbangio_i2c_read(self, args[ARG_address].u_int, diff --git a/shared-bindings/bitbangio/SPI.c b/shared-bindings/bitbangio/SPI.c index 3e1a62d8ed..5fcfcb1206 100644 --- a/shared-bindings/bitbangio/SPI.c +++ b/shared-bindings/bitbangio/SPI.c @@ -37,6 +37,7 @@ #include "lib/utils/context_manager_helpers.h" #include "py/mperrno.h" #include "py/runtime.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: bitbangio //| @@ -117,7 +118,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitbangio_spi_obj___exit___obj, 4, 4, static void check_lock(bitbangio_spi_obj_t *self) { if (!shared_module_bitbangio_spi_has_lock(self)) { - mp_raise_RuntimeError("Function requires lock"); + mp_raise_RuntimeError(translate("Function requires lock")); } } @@ -147,15 +148,15 @@ STATIC mp_obj_t bitbangio_spi_configure(size_t n_args, const mp_obj_t *pos_args, uint8_t polarity = args[ARG_polarity].u_int; if (polarity != 0 && polarity != 1) { - mp_raise_ValueError("Invalid polarity"); + mp_raise_ValueError(translate("Invalid polarity")); } uint8_t phase = args[ARG_phase].u_int; if (phase != 0 && phase != 1) { - mp_raise_ValueError("Invalid phase"); + mp_raise_ValueError(translate("Invalid phase")); } uint8_t bits = args[ARG_bits].u_int; if (bits != 8 && bits != 9) { - mp_raise_ValueError("Invalid number of bits"); + mp_raise_ValueError(translate("Invalid number of bits")); } shared_module_bitbangio_spi_configure(self, args[ARG_baudrate].u_int, polarity, phase, bits); @@ -280,7 +281,7 @@ STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_ normalize_buffer_bounds(&in_start, args[ARG_in_end].u_int, &in_length); if (out_length != in_length) { - mp_raise_ValueError("buffer slices must be of equal length"); + mp_raise_ValueError(translate("buffer slices must be of equal length")); } if (out_length == 0) { diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 0d21d30f00..dedcc0150c 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -34,6 +34,8 @@ #include "lib/utils/buffer_helper.h" #include "lib/utils/context_manager_helpers.h" #include "py/runtime.h" +#include "supervisor/shared/translate.h" + //| .. currentmodule:: busio //| //| :class:`I2C` --- Two wire serial protocol @@ -115,7 +117,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_i2c___exit___obj, 4, 4, busio_i static void check_lock(busio_i2c_obj_t *self) { asm(""); if (!common_hal_busio_i2c_has_lock(self)) { - mp_raise_RuntimeError("Function requires lock."); + mp_raise_RuntimeError(translate("Function requires lock.")); } } @@ -205,7 +207,7 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args, uint32_t length = bufinfo.len; normalize_buffer_bounds(&start, args[ARG_end].u_int, &length); if (length == 0) { - mp_raise_ValueError("Buffer must be at least length 1"); + mp_raise_ValueError(translate("Buffer must be at least length 1")); } uint8_t status = common_hal_busio_i2c_read(self, args[ARG_address].u_int, ((uint8_t*)bufinfo.buf) + start, length); diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 52c145d6de..7983a3a561 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -38,6 +38,7 @@ #include "py/mperrno.h" #include "py/objproperty.h" #include "py/runtime.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: busio //| @@ -129,7 +130,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_spi_obj___exit___obj, 4, 4, bus static void check_lock(busio_spi_obj_t *self) { asm(""); if (!common_hal_busio_spi_has_lock(self)) { - mp_raise_RuntimeError("Function requires lock"); + mp_raise_RuntimeError(translate("Function requires lock")); } } @@ -164,15 +165,15 @@ STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_ uint8_t polarity = args[ARG_polarity].u_int; if (polarity != 0 && polarity != 1) { - mp_raise_ValueError("Invalid polarity"); + mp_raise_ValueError(translate("Invalid polarity")); } uint8_t phase = args[ARG_phase].u_int; if (phase != 0 && phase != 1) { - mp_raise_ValueError("Invalid phase"); + mp_raise_ValueError(translate("Invalid phase")); } uint8_t bits = args[ARG_bits].u_int; if (bits != 8 && bits != 9) { - mp_raise_ValueError("Invalid number of bits"); + mp_raise_ValueError(translate("Invalid number of bits")); } if (!common_hal_busio_spi_configure(self, args[ARG_baudrate].u_int, @@ -337,7 +338,7 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args normalize_buffer_bounds(&in_start, args[ARG_in_end].u_int, &in_length); if (out_length != in_length) { - mp_raise_ValueError("buffer slices must be of equal length"); + mp_raise_ValueError(translate("buffer slices must be of equal length")); } if (out_length == 0) { diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 1b63d8d0e0..359334e5c5 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -36,6 +36,7 @@ #include "py/objproperty.h" #include "py/runtime.h" #include "py/stream.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: busio @@ -94,7 +95,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, si uint8_t bits = args[ARG_bits].u_int; if (bits < 7 || bits > 9) { - mp_raise_ValueError("bits must be 7, 8 or 9"); + mp_raise_ValueError(translate("bits must be 7, 8 or 9")); } uart_parity_t parity = PARITY_NONE; @@ -106,7 +107,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, si uint8_t stop = args[ARG_stop].u_int; if (stop != 1 && stop != 2) { - mp_raise_ValueError("stop must be 1 or 2"); + mp_raise_ValueError(translate("stop must be 1 or 2")); } common_hal_busio_uart_construct(self, tx, rx, @@ -304,7 +305,7 @@ STATIC const mp_rom_map_elem_t busio_uart_locals_dict_table[] = { // Properties { MP_ROM_QSTR(MP_QSTR_baudrate), MP_ROM_PTR(&busio_uart_baudrate_obj) }, - + // Nested Enum-like Classes. { MP_ROM_QSTR(MP_QSTR_Parity), MP_ROM_PTR(&busio_uart_parity_type) }, }; diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index 1270f84e40..2a1cd7761a 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -41,6 +41,7 @@ #include "shared-bindings/digitalio/DriveMode.h" #include "shared-bindings/digitalio/Pull.h" #include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: digitalio //| @@ -207,7 +208,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_direction(mp_obj_t self_in, mp_ob } else if (value == &digitalio_direction_output_obj) { common_hal_digitalio_digitalinout_switch_to_output(self, false, DRIVE_MODE_PUSH_PULL); } else { - mp_raise_ValueError("Invalid direction."); + mp_raise_ValueError(translate("Invalid direction.")); } return mp_const_none; } @@ -236,7 +237,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_value(mp_obj_t self_in, mp_obj_t digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in); raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self)); if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_INPUT) { - mp_raise_AttributeError("Cannot set value when direction is input."); + mp_raise_AttributeError(translate("Cannot set value when direction is input.")); return mp_const_none; } common_hal_digitalio_digitalinout_set_value(self, mp_obj_is_true(value)); @@ -262,7 +263,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj_get_drive_mode(mp_obj_t self_in) { digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in); raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self)); if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_INPUT) { - mp_raise_AttributeError("Drive mode not used when direction is input."); + mp_raise_AttributeError(translate("Drive mode not used when direction is input.")); return mp_const_none; } digitalio_drive_mode_t drive_mode = common_hal_digitalio_digitalinout_get_drive_mode(self); @@ -277,7 +278,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_drive_mode(mp_obj_t self_in, mp_o digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in); raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self)); if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_INPUT) { - mp_raise_AttributeError("Drive mode not used when direction is input."); + mp_raise_AttributeError(translate("Drive mode not used when direction is input.")); return mp_const_none; } digitalio_drive_mode_t c_drive_mode = DRIVE_MODE_PUSH_PULL; @@ -310,7 +311,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj_get_pull(mp_obj_t self_in) { digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in); raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self)); if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_OUTPUT) { - mp_raise_AttributeError("Pull not used when direction is output."); + mp_raise_AttributeError(translate("Pull not used when direction is output.")); return mp_const_none; } digitalio_pull_t pull = common_hal_digitalio_digitalinout_get_pull(self); @@ -327,7 +328,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_pull(mp_obj_t self_in, mp_obj_t p digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in); raise_error_if_deinited(common_hal_digitalio_digitalinout_deinited(self)); if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_OUTPUT) { - mp_raise_AttributeError("Pull not used when direction is output."); + mp_raise_AttributeError(translate("Pull not used when direction is output.")); return mp_const_none; } digitalio_pull_t pull = PULL_NONE; @@ -336,7 +337,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_pull(mp_obj_t self_in, mp_obj_t p } else if (pull_obj == &digitalio_pull_down_obj) { pull = PULL_DOWN; } else if (pull_obj != mp_const_none) { - mp_raise_ValueError("Unsupported pull value."); + mp_raise_ValueError(translate("Unsupported pull value.")); } common_hal_digitalio_digitalinout_set_pull(self, pull); return mp_const_none; diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c index 1e95776d70..21da4fab90 100644 --- a/shared-bindings/gamepad/GamePad.c +++ b/shared-bindings/gamepad/GamePad.c @@ -32,6 +32,7 @@ #include "shared-module/gamepad/GamePad.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" #include "GamePad.h" @@ -96,11 +97,11 @@ STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { if (n_args > 8) { - mp_raise_TypeError("too many arguments"); + mp_raise_TypeError(translate("too many arguments")); } for (size_t i = 0; i < n_args; ++i) { if (!MP_OBJ_IS_TYPE(args[i], &digitalio_digitalinout_type)) { - mp_raise_TypeError("expected a DigitalInOut"); + mp_raise_TypeError(translate("expected a DigitalInOut")); } digitalio_digitalinout_obj_t *pin = MP_OBJ_TO_PTR(args[i]); raise_error_if_deinited( @@ -157,4 +158,3 @@ const mp_obj_type_t gamepad_type = { .make_new = gamepad_make_new, .locals_dict = (mp_obj_dict_t*)&gamepad_locals_dict, }; - diff --git a/shared-bindings/help.c b/shared-bindings/help.c index d8ffc13dd0..78301a91a9 100644 --- a/shared-bindings/help.c +++ b/shared-bindings/help.c @@ -35,10 +35,11 @@ //| prints general port information. //| +// TODO(tannewt): Figure out how to translate this. Its weird because its a global string. + const char circuitpython_help_text[] = "Welcome to Adafruit CircuitPython " MICROPY_GIT_TAG "!\r\n" "\r\n" "Please visit learn.adafruit.com/category/circuitpython for project guides.\r\n" "\r\n" "To list built-in modules please do `help(\"modules\")`.\r\n"; -; diff --git a/shared-bindings/math/__init__.c b/shared-bindings/math/__init__.c index 84827842f8..0bf8047c98 100644 --- a/shared-bindings/math/__init__.c +++ b/shared-bindings/math/__init__.c @@ -27,7 +27,7 @@ #include "py/builtin.h" #include "py/runtime.h" -#include "py/runtime.h" +#include "supervisor/shared/translate.h" #if MICROPY_PY_BUILTINS_FLOAT @@ -50,7 +50,7 @@ //| STATIC NORETURN void math_error(void) { - mp_raise_ValueError("math domain error"); + mp_raise_ValueError(translate("math domain error")); } #define MATH_FUN_1(py_name, c_name) \ @@ -343,7 +343,7 @@ STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) { #pragma GCC diagnostic ignored "-Wfloat-equal" } else if (base == (mp_float_t)1.0) { #pragma GCC diagnostic pop - mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero"); + mp_raise_msg(&mp_type_ZeroDivisionError, translate("division by zero")); } return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base)); } diff --git a/shared-bindings/microcontroller/Pin.c b/shared-bindings/microcontroller/Pin.c index c456a030f9..7ed95ba3bb 100644 --- a/shared-bindings/microcontroller/Pin.c +++ b/shared-bindings/microcontroller/Pin.c @@ -31,6 +31,7 @@ #include "py/nlr.h" #include "py/obj.h" #include "py/runtime.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: microcontroller //| @@ -85,7 +86,7 @@ const mp_obj_type_t mcu_pin_type = { void assert_pin(mp_obj_t obj, bool none_ok) { if ((obj != mp_const_none || !none_ok) && !MP_OBJ_IS_TYPE(obj, &mcu_pin_type)) { - mp_raise_TypeError_varg("Expected a %q", mcu_pin_type.name); + mp_raise_TypeError_varg(translate("Expected a %q"), mcu_pin_type.name); } } diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index 0c627cdf9e..da8d0bd940 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -39,8 +39,8 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Processor.h" - #include "py/runtime.h" +#include "supervisor/shared/translate.h" //| :mod:`microcontroller` --- Pin references and cpu functionality //| ================================================================ @@ -123,7 +123,7 @@ STATIC mp_obj_t mcu_on_next_reset(mp_obj_t run_mode_obj) { } else if (run_mode_obj == &mcu_runmode_bootloader_obj) { run_mode = RUNMODE_BOOTLOADER; } else { - mp_raise_ValueError("Invalid run mode."); + mp_raise_ValueError(translate("Invalid run mode.")); } common_hal_mcu_on_next_reset(run_mode); diff --git a/shared-bindings/multiterminal/__init__.c b/shared-bindings/multiterminal/__init__.c index 32dcdd75d6..8de3c50d7b 100644 --- a/shared-bindings/multiterminal/__init__.c +++ b/shared-bindings/multiterminal/__init__.c @@ -23,12 +23,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "shared-bindings/multiterminal/__init__.h" #include "py/obj.h" #include "py/mphal.h" #include "py/runtime.h" - -#include "shared-bindings/multiterminal/__init__.h" +#include "supervisor/shared/translate.h" //| :mod:`multiterminal` --- Manage additional terminal sources //| =========================================================== @@ -65,7 +65,7 @@ STATIC mp_obj_t multiterminal_obj_set_secondary_terminal(mp_obj_t secondary_term mp_obj_t readinto_m[3]; mp_load_method_maybe(secondary_terminal, MP_QSTR_readinto, readinto_m); if (write_m[0] == MP_OBJ_NULL || readinto_m[0] == MP_OBJ_NULL) { - mp_raise_ValueError("Stream missing readinto() or write() method."); + mp_raise_ValueError(translate("Stream missing readinto() or write() method.")); return mp_const_none; } common_hal_multiterminal_set_secondary_terminal(secondary_terminal); diff --git a/shared-bindings/multiterminal/__init__.h b/shared-bindings/multiterminal/__init__.h index 91099a5dfe..7c28842630 100644 --- a/shared-bindings/multiterminal/__init__.h +++ b/shared-bindings/multiterminal/__init__.h @@ -27,6 +27,8 @@ #ifndef SHARED_BINDINGS_MULTITERMINAL___INIT___H #define SHARED_BINDINGS_MULTITERMINAL___INIT___H +#include "py/obj.h" + void common_hal_multiterminal_schedule_secondary_terminal_read(mp_obj_t socket); mp_obj_t common_hal_multiterminal_get_secondary_terminal(); void common_hal_multiterminal_set_secondary_terminal(mp_obj_t secondary_terminal); diff --git a/shared-bindings/neopixel_write/__init__.c b/shared-bindings/neopixel_write/__init__.c index c3c475c7cc..05d6fd97ae 100644 --- a/shared-bindings/neopixel_write/__init__.c +++ b/shared-bindings/neopixel_write/__init__.c @@ -23,13 +23,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "shared-bindings/neopixel_write/__init__.h" #include "py/obj.h" #include "py/mphal.h" #include "py/runtime.h" - #include "shared-bindings/digitalio/DigitalInOut.h" -#include "shared-bindings/neopixel_write/__init__.h" +#include "supervisor/shared/translate.h" //| :mod:`neopixel_write` --- Low-level neopixel implementation //| =========================================================== @@ -64,7 +64,7 @@ //| STATIC mp_obj_t neopixel_write_neopixel_write_(mp_obj_t digitalinout_obj, mp_obj_t buf) { if (!MP_OBJ_IS_TYPE(digitalinout_obj, &digitalio_digitalinout_type)) { - mp_raise_TypeError_varg("Expected a %q", digitalio_digitalinout_type.name); + mp_raise_TypeError_varg(translate("Expected a %q"), digitalio_digitalinout_type.name); } // Convert parameters into expected types. const digitalio_digitalinout_obj_t *digitalinout = MP_OBJ_TO_PTR(digitalinout_obj); diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c index 56337df403..22cd838b1e 100644 --- a/shared-bindings/nvm/ByteArray.c +++ b/shared-bindings/nvm/ByteArray.c @@ -29,6 +29,7 @@ #include "py/runtime.h" #include "py/runtime0.h" #include "shared-bindings/nvm/ByteArray.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: nvm //| @@ -81,7 +82,7 @@ STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj } else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) { mp_bound_slice_t slice; if (!mp_seq_get_fast_slice_indexes(common_hal_nvm_bytearray_get_length(self), index_in, &slice)) { - mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported"); + mp_raise_NotImplementedError(translate("only slices with step=1 (aka None) are supported")); } if (value != MP_OBJ_SENTINEL) { #if MICROPY_PY_ARRAY_SLICE_ASSIGN @@ -95,19 +96,19 @@ STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj mp_buffer_info_t bufinfo; mp_get_buffer_raise(value, &bufinfo, MP_BUFFER_READ); if (bufinfo.len != src_len) { - mp_raise_ValueError("Slice and value different lengths."); + mp_raise_ValueError(translate("Slice and value different lengths.")); } src_len = bufinfo.len; src_items = bufinfo.buf; if (1 != mp_binary_get_size('@', bufinfo.typecode, NULL)) { - mp_raise_ValueError("Array values should be single bytes."); + mp_raise_ValueError(translate("Array values should be single bytes.")); } } else { - mp_raise_NotImplementedError("array/bytes required on right side"); + mp_raise_NotImplementedError(translate("array/bytes required on right side")); } if (!common_hal_nvm_bytearray_set_bytes(self, slice.start, src_items, src_len)) { - mp_raise_RuntimeError("Unable to write to nvm."); + mp_raise_RuntimeError(translate("Unable to write to nvm.")); } return mp_const_none; #else @@ -133,11 +134,11 @@ STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj // store mp_int_t byte_value = mp_obj_get_int(value); if (byte_value > 0xff || byte_value < 0) { - mp_raise_ValueError("Bytes must be between 0 and 255."); + mp_raise_ValueError(translate("Bytes must be between 0 and 255.")); } uint8_t short_value = byte_value; if (!common_hal_nvm_bytearray_set_bytes(self, index, &short_value, 1)) { - mp_raise_RuntimeError("Unable to write to nvm."); + mp_raise_RuntimeError(translate("Unable to write to nvm.")); } return mp_const_none; } diff --git a/shared-bindings/pulseio/PWMOut.c b/shared-bindings/pulseio/PWMOut.c index 8f6c766808..9b7094b4ef 100644 --- a/shared-bindings/pulseio/PWMOut.c +++ b/shared-bindings/pulseio/PWMOut.c @@ -33,6 +33,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/pulseio/PWMOut.h" #include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: pulseio //| @@ -160,7 +161,7 @@ STATIC mp_obj_t pulseio_pwmout_obj_set_duty_cycle(mp_obj_t self_in, mp_obj_t dut raise_error_if_deinited(common_hal_pulseio_pwmout_deinited(self)); mp_int_t duty = mp_obj_get_int(duty_cycle); if (duty < 0 || duty > 0xffff) { - mp_raise_ValueError("PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)"); + mp_raise_ValueError(translate("PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)")); } common_hal_pulseio_pwmout_set_duty_cycle(self, duty); return mp_const_none; @@ -190,9 +191,9 @@ STATIC mp_obj_t pulseio_pwmout_obj_set_frequency(mp_obj_t self_in, mp_obj_t freq pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in); raise_error_if_deinited(common_hal_pulseio_pwmout_deinited(self)); if (!common_hal_pulseio_pwmout_get_variable_frequency(self)) { - mp_raise_AttributeError( + mp_raise_AttributeError(translate( "PWM frequency not writeable when variable_frequency is False on " - "construction."); + "construction.")); } common_hal_pulseio_pwmout_set_frequency(self, mp_obj_get_int(frequency)); return mp_const_none; diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index 862dbd99d6..acf88b9fbe 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -33,6 +33,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/pulseio/PulseIn.h" #include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: pulseio //| @@ -271,25 +272,25 @@ STATIC mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) { STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { if (value == mp_const_none) { // delete item - mp_raise_AttributeError("Cannot delete values"); + mp_raise_AttributeError(translate("Cannot delete values")); } else { pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in); raise_error_if_deinited(common_hal_pulseio_pulsein_deinited(self)); if (MP_OBJ_IS_TYPE(index_obj, &mp_type_slice)) { - mp_raise_NotImplementedError("Slices not supported"); + mp_raise_NotImplementedError(translate("Slices not supported")); } else { uint16_t index = 0; if (MP_OBJ_IS_SMALL_INT(index_obj)) { index = MP_OBJ_SMALL_INT_VALUE(index_obj); } else { - mp_raise_TypeError("index must be int"); + mp_raise_TypeError(translate("index must be int")); } if (value == MP_OBJ_SENTINEL) { // load return MP_OBJ_NEW_SMALL_INT(common_hal_pulseio_pulsein_get_item(self, index)); } else { - mp_raise_AttributeError("Read-only"); + mp_raise_AttributeError(translate("Read-only")); } } } diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c index dc3c025008..1c97c37c36 100644 --- a/shared-bindings/pulseio/PulseOut.c +++ b/shared-bindings/pulseio/PulseOut.c @@ -34,6 +34,7 @@ #include "shared-bindings/pulseio/PulseOut.h" #include "shared-bindings/pulseio/PWMOut.h" #include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: pulseio //| @@ -71,7 +72,7 @@ STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_ar mp_obj_t carrier_obj = args[0]; if (!MP_OBJ_IS_TYPE(carrier_obj, &pulseio_pwmout_type)) { - mp_raise_TypeError_varg("Expected a %q", pulseio_pwmout_type.name); + mp_raise_TypeError_varg(translate("Expected a %q"), pulseio_pwmout_type.name); } // create Pulse object from the given pin @@ -130,7 +131,7 @@ STATIC mp_obj_t pulseio_pulseout_obj_send(mp_obj_t self_in, mp_obj_t pulses) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(pulses, &bufinfo, MP_BUFFER_READ); if (bufinfo.typecode != 'H') { - mp_raise_TypeError("Array must contain halfwords (type 'H')"); + mp_raise_TypeError(translate("Array must contain halfwords (type 'H')")); } common_hal_pulseio_pulseout_send(self, (uint16_t *)bufinfo.buf, bufinfo.len / 2); return mp_const_none; diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index cea437e98d..83698eac57 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -31,6 +31,7 @@ #include "py/obj.h" #include "py/runtime.h" #include "shared-bindings/random/__init__.h" +#include "supervisor/shared/translate.h" //| :mod:`random` --- psuedo-random numbers and choices //| ======================================================== @@ -88,7 +89,7 @@ STATIC mp_obj_t random_randrange(size_t n_args, const mp_obj_t *args) { if (n_args == 1) { // range(stop) if (stop <= 0) { - mp_raise_ValueError("stop not reachable from start"); + mp_raise_ValueError(translate("stop not reachable from start")); } } else { start = stop; @@ -96,7 +97,7 @@ STATIC mp_obj_t random_randrange(size_t n_args, const mp_obj_t *args) { if (n_args == 2) { // range(start, stop) if (start >= stop) { - mp_raise_ValueError("stop not reachable from start"); + mp_raise_ValueError(translate("stop not reachable from start")); } } else { // range(start, stop, step) @@ -107,10 +108,10 @@ STATIC mp_obj_t random_randrange(size_t n_args, const mp_obj_t *args) { } else if (step < 0) { n = (stop - start + step + 1) / step; } else { - mp_raise_ValueError("step must be non-zero"); + mp_raise_ValueError(translate("step must be non-zero")); } if (n <= 0) { - mp_raise_ValueError("invalid step"); + mp_raise_ValueError(translate("invalid step")); } } } @@ -142,7 +143,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(random_randint_obj, random_randint); STATIC mp_obj_t random_choice(mp_obj_t seq) { mp_int_t len = mp_obj_get_int(mp_obj_len(seq)); if (len == 0) { - mp_raise_IndexError("empty sequence"); + mp_raise_IndexError(translate("empty sequence")); } return mp_obj_subscr(seq, mp_obj_new_int(shared_modules_random_randrange(0, len, 1)), MP_OBJ_SENTINEL); } diff --git a/shared-bindings/rtc/RTC.c b/shared-bindings/rtc/RTC.c index aeedad12d9..a0e9be3020 100644 --- a/shared-bindings/rtc/RTC.c +++ b/shared-bindings/rtc/RTC.c @@ -34,13 +34,14 @@ #include "shared-bindings/rtc/__init__.h" #include "shared-bindings/rtc/RTC.h" #include "shared-bindings/time/__init__.h" +#include "supervisor/shared/translate.h" void MP_WEAK common_hal_rtc_get_time(timeutils_struct_time_t *tm) { - mp_raise_NotImplementedError("RTC is not supported on this board"); + mp_raise_NotImplementedError(translate("RTC is not supported on this board")); } void MP_WEAK common_hal_rtc_set_time(timeutils_struct_time_t *tm) { - mp_raise_NotImplementedError("RTC is not supported on this board"); + mp_raise_NotImplementedError(translate("RTC is not supported on this board")); } int MP_WEAK common_hal_rtc_get_calibration(void) { @@ -48,7 +49,7 @@ int MP_WEAK common_hal_rtc_get_calibration(void) { } void MP_WEAK common_hal_rtc_set_calibration(int calibration) { - mp_raise_NotImplementedError("RTC calibration is not supported on this board"); + mp_raise_NotImplementedError(translate("RTC calibration is not supported on this board")); } const rtc_rtc_obj_t rtc_rtc_obj = {{&rtc_rtc_type}}; diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index 1cfeea59c1..3484b9af82 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -33,6 +33,7 @@ #include "py/objnamedtuple.h" #include "py/runtime.h" #include "shared-bindings/storage/__init__.h" +#include "supervisor/shared/translate.h" //| :mod:`storage` --- storage management //| ======================================================== @@ -73,7 +74,7 @@ mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_arg mp_obj_t dest[2]; mp_load_method_maybe(vfs_obj, MP_QSTR_mount, dest); if (dest[0] == MP_OBJ_NULL) { - mp_raise_ValueError("filesystem must provide mount method"); + mp_raise_ValueError(translate("filesystem must provide mount method")); } common_hal_storage_mount(vfs_obj, mnt_str, mp_obj_is_true(args[ARG_readonly].u_obj)); diff --git a/shared-bindings/struct/__init__.c b/shared-bindings/struct/__init__.c index 5be2559718..0935977859 100644 --- a/shared-bindings/struct/__init__.c +++ b/shared-bindings/struct/__init__.c @@ -36,6 +36,7 @@ #include "py/parsenum.h" #include "shared-bindings/struct/__init__.h" #include "shared-module/struct/__init__.h" +#include "supervisor/shared/translate.h" //| :mod:`struct` --- manipulation of c-style data //| ======================================================== @@ -85,7 +86,6 @@ STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) { } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_obj, 1, MP_OBJ_FUN_ARGS_MAX, struct_pack); - //| .. function:: pack_into(fmt, buffer, offset, v1, v2, ...) //| //| Pack the values v1, v2, ... according to the format string fmt into a buffer @@ -100,7 +100,7 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) { // negative offsets are relative to the end of the buffer offset = (mp_int_t)bufinfo.len + offset; if (offset < 0) { - mp_raise_RuntimeError("buffer too small"); + mp_raise_RuntimeError(translate("buffer too small")); } } byte *p = (byte *)bufinfo.buf; @@ -142,7 +142,7 @@ STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) { // negative offsets are relative to the end of the buffer offset = bufinfo.len + offset; if (offset < 0) { - mp_raise_RuntimeError("buffer too small"); + mp_raise_RuntimeError(translate("buffer too small")); } } p += offset; diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index b9bcc55443..2705c8e581 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -31,6 +31,7 @@ #include "supervisor/shared/autoreload.h" #include "supervisor/shared/rgb_led_status.h" #include "supervisor/shared/stack.h" +#include "supervisor/shared/translate.h" #include "shared-bindings/supervisor/__init__.h" #include "shared-bindings/supervisor/Runtime.h" @@ -89,7 +90,7 @@ STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl){ // This must be int. If cast to uint8_t first, will never raise a ValueError. int brightness_int = mp_obj_get_int(lvl); if(brightness_int < 0 || brightness_int > 255){ - mp_raise_ValueError("Brightness must be between 0 and 255"); + mp_raise_ValueError(translate("Brightness must be between 0 and 255")); } set_rgb_status_brightness((uint8_t)brightness_int); return mp_const_none; @@ -115,7 +116,7 @@ STATIC mp_obj_t supervisor_set_next_stack_limit(mp_obj_t size_obj) { mp_int_t size = mp_obj_get_int(size_obj); if (size < 256) { - mp_raise_ValueError("Stack size must be at least 256"); + mp_raise_ValueError(translate("Stack size must be at least 256")); } set_next_stack_size(size); diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index 6a4dc90e21..83bbbe2cd4 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -34,6 +34,7 @@ #include "lib/timeutils/timeutils.h" #include "shared-bindings/rtc/__init__.h" #include "shared-bindings/time/__init__.h" +#include "supervisor/shared/translate.h" #define EPOCH1970_EPOCH2000_DIFF_SECS 946684800 @@ -76,7 +77,7 @@ STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) { int seconds = mp_obj_get_int(seconds_o); #endif if (seconds < 0) { - mp_raise_ValueError("sleep length must be non-negative"); + mp_raise_ValueError(translate("sleep length must be non-negative")); } common_hal_time_delay_ms(1000 * seconds); return mp_const_none; @@ -86,10 +87,10 @@ MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_obj, time_sleep); #if MICROPY_PY_COLLECTIONS mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { if (n_args != 1) { - mp_raise_TypeError("time.struct_time() takes exactly 1 argument"); + mp_raise_TypeError(translate("time.struct_time() takes exactly 1 argument")); } if (!MP_OBJ_IS_TYPE(args[0], &mp_type_tuple) || ((mp_obj_tuple_t*) MP_OBJ_TO_PTR(args[0]))->len != 9) { - mp_raise_TypeError("time.struct_time() takes a 9-sequence"); + mp_raise_TypeError(translate("time.struct_time() takes a 9-sequence")); } mp_obj_tuple_t* tuple = MP_OBJ_TO_PTR(args[0]); @@ -167,12 +168,12 @@ void struct_time_to_tm(mp_obj_t t, timeutils_struct_time_t *tm) { size_t len; if (!MP_OBJ_IS_TYPE(t, &mp_type_tuple) && !MP_OBJ_IS_TYPE(t, MP_OBJ_FROM_PTR(&struct_time_type_obj))) { - mp_raise_TypeError("Tuple or struct_time argument required"); + mp_raise_TypeError(translate("Tuple or struct_time argument required")); } mp_obj_tuple_get(t, &len, &elems); if (len != 9) { - mp_raise_TypeError("function takes exactly 9 arguments"); + mp_raise_TypeError(translate("function takes exactly 9 arguments")); } tm->tm_year = mp_obj_get_int(elems[0]); @@ -188,7 +189,7 @@ void struct_time_to_tm(mp_obj_t t, timeutils_struct_time_t *tm) { #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE mp_obj_t MP_WEAK rtc_get_time_source_time(void) { - mp_raise_RuntimeError("RTC is not supported on this board"); + mp_raise_RuntimeError(translate("RTC is not supported on this board")); } //| .. method:: time() @@ -224,7 +225,7 @@ STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) { mp_int_t secs = mp_obj_int_get_checked(args[0]); if (secs < EPOCH1970_EPOCH2000_DIFF_SECS) - mp_raise_msg(&mp_type_OverflowError, "timestamp out of range for platform time_t"); + mp_raise_msg(&mp_type_OverflowError, translate("timestamp out of range for platform time_t")); timeutils_struct_time_t tm; timeutils_seconds_since_2000_to_struct_time(secs - EPOCH1970_EPOCH2000_DIFF_SECS, &tm); @@ -248,16 +249,16 @@ STATIC mp_obj_t time_mktime(mp_obj_t t) { size_t len; if (!MP_OBJ_IS_TYPE(t, &mp_type_tuple) && !MP_OBJ_IS_TYPE(t, MP_OBJ_FROM_PTR(&struct_time_type_obj))) { - mp_raise_TypeError("Tuple or struct_time argument required"); + mp_raise_TypeError(translate("Tuple or struct_time argument required")); } mp_obj_tuple_get(t, &len, &elem); if (len != 9) { - mp_raise_TypeError("function takes exactly 9 arguments"); + mp_raise_TypeError(translate("function takes exactly 9 arguments")); } if (mp_obj_get_int(elem[0]) < 2000) - mp_raise_msg(&mp_type_OverflowError, "timestamp out of range for platform time_t"); + mp_raise_msg(&mp_type_OverflowError, translate("timestamp out of range for platform time_t")); mp_uint_t secs = timeutils_mktime(mp_obj_get_int(elem[0]), mp_obj_get_int(elem[1]), mp_obj_get_int(elem[2]), mp_obj_get_int(elem[3]), mp_obj_get_int(elem[4]), mp_obj_get_int(elem[5])); diff --git a/shared-bindings/touchio/TouchIn.c b/shared-bindings/touchio/TouchIn.c index 710260faf3..326b0212ef 100644 --- a/shared-bindings/touchio/TouchIn.c +++ b/shared-bindings/touchio/TouchIn.c @@ -36,6 +36,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/touchio/TouchIn.h" #include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" //| .. currentmodule:: touchio //| @@ -169,7 +170,7 @@ STATIC mp_obj_t touchio_touchin_obj_set_threshold(mp_obj_t self_in, mp_obj_t thr uint32_t new_threshold = mp_obj_get_int(threshold_obj); if (new_threshold < 0 || new_threshold > UINT16_MAX) { // I would use MP_STRINGIFY(UINT16_MAX), but that prints "0xffff" instead of 65536. - mp_raise_ValueError("threshold must be in the range 0-65536"); + mp_raise_ValueError(translate("threshold must be in the range 0-65536")); } common_hal_touchio_touchin_set_threshold(self, new_threshold); return mp_const_none; diff --git a/shared-bindings/util.c b/shared-bindings/util.c index 3dadc4c189..80a0bdaebc 100644 --- a/shared-bindings/util.c +++ b/shared-bindings/util.c @@ -30,11 +30,12 @@ #include "py/runtime.h" #include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" // Check if pin is None. If so, deinit() has already been called on the object, so complain. void raise_error_if_deinited(bool deinited) { if (deinited) { - mp_raise_ValueError("Object has been deinitialized and can no longer be used. Create a new object."); + mp_raise_ValueError(translate("Object has been deinitialized and can no longer be used. Create a new object.")); } } diff --git a/shared-module/audioio/WaveFile.c b/shared-module/audioio/WaveFile.c index 7247db137a..ce58776294 100644 --- a/shared-module/audioio/WaveFile.c +++ b/shared-module/audioio/WaveFile.c @@ -33,6 +33,7 @@ #include "py/runtime.h" #include "shared-module/audioio/WaveFile.h" +#include "supervisor/shared/translate.h" struct wave_format_chunk { uint16_t audio_format; @@ -57,7 +58,7 @@ void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t* self, if (bytes_read != 16 || memcmp(chunk_header, "RIFF", 4) != 0 || memcmp(chunk_header + 8, "WAVEfmt ", 8) != 0) { - mp_raise_ValueError("Invalid wave file"); + mp_raise_ValueError(translate("Invalid wave file")); } uint32_t format_size; if (f_read(&self->file->fp, &format_size, 4, &bytes_read) != FR_OK) { @@ -65,7 +66,7 @@ void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t* self, } if (bytes_read != 4 || format_size > sizeof(struct wave_format_chunk)) { - mp_raise_ValueError("Invalid format chunk size"); + mp_raise_ValueError(translate("Invalid format chunk size")); } struct wave_format_chunk format; if (f_read(&self->file->fp, &format, format_size, &bytes_read) != FR_OK) { @@ -79,7 +80,7 @@ void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t* self, format.bits_per_sample > 16 || (format_size == 18 && format.extra_params != 0)) { - mp_raise_ValueError("Unsupported format"); + mp_raise_ValueError(translate("Unsupported format")); } // Get the sample_rate self->sample_rate = format.sample_rate; @@ -95,7 +96,7 @@ void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t* self, } if (bytes_read != 4 || memcmp((uint8_t *) data_tag, "data", 4) != 0) { - mp_raise_ValueError("Data chunk must follow fmt chunk"); + mp_raise_ValueError(translate("Data chunk must follow fmt chunk")); } uint32_t data_length; @@ -103,7 +104,7 @@ void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t* self, mp_raise_OSError(MP_EIO); } if (bytes_read != 4) { - mp_raise_ValueError("Invalid file"); + mp_raise_ValueError(translate("Invalid file")); } self->file_length = data_length; self->data_start = self->file->fp.fptr; diff --git a/shared-module/bitbangio/I2C.c b/shared-module/bitbangio/I2C.c index 47529748a5..5a9ac9a991 100644 --- a/shared-module/bitbangio/I2C.c +++ b/shared-module/bitbangio/I2C.c @@ -33,7 +33,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-module/bitbangio/types.h" - +#include "supervisor/shared/translate.h" STATIC void delay(bitbangio_i2c_obj_t *self) { // We need to use an accurate delay to get acceptable I2C @@ -55,7 +55,7 @@ STATIC void scl_release(bitbangio_i2c_obj_t *self) { } // raise exception on timeout if (count == 0) { - mp_raise_msg(&mp_type_TimeoutError, "Clock stretch too long"); + mp_raise_msg(&mp_type_TimeoutError, translate("Clock stretch too long")); } } diff --git a/shared-module/bitbangio/SPI.c b/shared-module/bitbangio/SPI.c index b203fe1b42..9e45083552 100644 --- a/shared-module/bitbangio/SPI.c +++ b/shared-module/bitbangio/SPI.c @@ -33,6 +33,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-module/bitbangio/types.h" +#include "supervisor/shared/translate.h" #define MAX_BAUDRATE (common_hal_mcu_get_clock_frequency() / 48) @@ -41,13 +42,13 @@ void shared_module_bitbangio_spi_construct(bitbangio_spi_obj_t *self, const mcu_pin_obj_t * miso) { digitalinout_result_t result = common_hal_digitalio_digitalinout_construct(&self->clock, clock); if (result != DIGITALINOUT_OK) { - mp_raise_ValueError("Clock pin init failed."); + mp_raise_ValueError(translate("Clock pin init failed.")); } if (mosi != mp_const_none) { result = common_hal_digitalio_digitalinout_construct(&self->mosi, mosi); if (result != DIGITALINOUT_OK) { common_hal_digitalio_digitalinout_deinit(&self->clock); - mp_raise_ValueError("MOSI pin init failed."); + mp_raise_ValueError(translate("MOSI pin init failed.")); } self->has_mosi = true; } @@ -58,7 +59,7 @@ void shared_module_bitbangio_spi_construct(bitbangio_spi_obj_t *self, if (mosi != mp_const_none) { common_hal_digitalio_digitalinout_deinit(&self->mosi); } - mp_raise_ValueError("MISO pin init failed."); + mp_raise_ValueError(translate("MISO pin init failed.")); } self->has_miso = true; } @@ -118,7 +119,7 @@ void shared_module_bitbangio_spi_unlock(bitbangio_spi_obj_t *self) { // Writes out the given data. bool shared_module_bitbangio_spi_write(bitbangio_spi_obj_t *self, const uint8_t *data, size_t len) { if (len > 0 && !self->has_mosi) { - mp_raise_ValueError("Cannot write without MOSI pin."); + mp_raise_ValueError(translate("Cannot write without MOSI pin.")); } uint32_t delay_half = self->delay_half; @@ -173,7 +174,7 @@ bool shared_module_bitbangio_spi_write(bitbangio_spi_obj_t *self, const uint8_t // Reads in len bytes while outputting zeroes. bool shared_module_bitbangio_spi_read(bitbangio_spi_obj_t *self, uint8_t *data, size_t len) { if (len > 0 && !self->has_miso) { - mp_raise_ValueError("Cannot read without MISO pin."); + mp_raise_ValueError(translate("Cannot read without MISO pin.")); } uint32_t delay_half = self->delay_half; @@ -237,7 +238,7 @@ bool shared_module_bitbangio_spi_read(bitbangio_spi_obj_t *self, uint8_t *data, // transfer bool shared_module_bitbangio_spi_transfer(bitbangio_spi_obj_t *self, const uint8_t *dout, uint8_t *din, size_t len) { if (len > 0 && (!self->has_mosi || !self->has_miso) ) { - mp_raise_ValueError("Cannot transfer without MOSI and MISO pins."); + mp_raise_ValueError(translate("Cannot transfer without MOSI and MISO pins.")); } uint32_t delay_half = self->delay_half; diff --git a/shared-module/struct/__init__.c b/shared-module/struct/__init__.c index eac41c9c31..78c04f07ba 100644 --- a/shared-module/struct/__init__.c +++ b/shared-module/struct/__init__.c @@ -31,11 +31,12 @@ #include "py/runtime.h" #include "py/binary.h" #include "py/parsenum.h" +#include "supervisor/shared/translate.h" void struct_validate_format(char fmt) { #if MICROPY_NONSTANDARD_TYPECODES if( fmt == 'S' || fmt == 'O') { - mp_raise_RuntimeError("'S' and 'O' are not supported format types"); + mp_raise_RuntimeError(translate("'S' and 'O' are not supported format types")); } #endif } @@ -70,7 +71,6 @@ mp_uint_t get_fmt_num(const char **p) { return val; } - void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte* end_p, size_t n_args, const mp_obj_t *args) { const char *fmt = mp_obj_str_get_str(fmt_in); char fmt_type = get_fmt_type(&fmt); @@ -80,7 +80,7 @@ void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte* end_p, size mp_uint_t sz = 1; if (*fmt == '\0') { // more arguments given than used by format string; CPython raises struct.error here - mp_raise_RuntimeError("too many arguments provided with the given format"); + mp_raise_RuntimeError(translate("too many arguments provided with the given format")); } struct_validate_format(*fmt); @@ -88,7 +88,7 @@ void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte* end_p, size sz = get_fmt_num(&fmt); } if (p + sz > end_p) { - mp_raise_RuntimeError("buffer too small"); + mp_raise_RuntimeError(translate("buffer too small")); } if (*fmt == 's') { @@ -172,7 +172,7 @@ mp_obj_tuple_t * shared_modules_struct_unpack_from(mp_obj_t fmt_in, byte *p, byt sz = get_fmt_num(&fmt); } if (p + sz > end_p) { - mp_raise_RuntimeError("buffer too small"); + mp_raise_RuntimeError(translate("buffer too small")); } mp_obj_t item; if (*fmt == 's') { diff --git a/supervisor/shared/translate.c b/supervisor/shared/translate.c new file mode 100644 index 0000000000..570b4501ec --- /dev/null +++ b/supervisor/shared/translate.c @@ -0,0 +1,42 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/shared/translate.h" + +#include + +inline __attribute__((always_inline)) const char* translate(const char* c) { + #ifndef NO_QSTR + #define QDEF(id, str) + #define TRANSLATION(id, str) if (strcmp(c, id) == 0) { return str; } else + #include "genhdr/qstrdefs.generated.h" + #undef TRANSLATION + #undef QDEF + #endif + { + return ""; + } +} diff --git a/supervisor/messages/en-US.h b/supervisor/shared/translate.h similarity index 79% rename from supervisor/messages/en-US.h rename to supervisor/shared/translate.h index d31e3b67ae..bd474e7ebb 100644 --- a/supervisor/messages/en-US.h +++ b/supervisor/shared/translate.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,12 +24,9 @@ * THE SOFTWARE. */ -#ifndef MICROPY_SUPERVISOR_MESSAGES_EN_US_H -#define MICROPY_SUPERVISOR_MESSAGES_EN_US_H +#ifndef MICROPY_INCLUDED_SUPERVISOR_TRANSLATE_H +#define MICROPY_INCLUDED_SUPERVISOR_TRANSLATE_H -// Place override messages here. +const char* translate(const char* c); -// Leave this at the bottom. -#include "supervisor/messages/default.h" - -#endif // MICROPY_SUPERVISOR_MESSAGES_EN_US_H +#endif // MICROPY_INCLUDED_SUPERVISOR_TRANSLATE_H diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 20de58001f..e516dcb2da 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -3,7 +3,8 @@ SRC_SUPERVISOR = \ supervisor/port.c \ supervisor/shared/autoreload.c \ supervisor/shared/rgb_led_status.c \ - supervisor/shared/stack.c + supervisor/shared/stack.c \ + supervisor/shared/translate.c ifeq ($(wildcard atmel-samd/supervisor/filesystem.c),) SRC_SUPERVISOR += supervisor/filesystem.c @@ -18,3 +19,5 @@ else endif SUPERVISOR_O = $(addprefix $(BUILD)/, $(SRC_SUPERVISOR:.c=.o)) + +$(BUILD)/supervisor/shared/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h diff --git a/tools/build_adafruit_bins.sh b/tools/build_adafruit_bins.sh index 29ee35c6ad..94c6a3646f 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 + 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 || $? )) - 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 - (( 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 0000000000..4bea040bfe --- /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 eeb760a5f6..7deb76a8d3 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: