summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2018-11-09 16:41:08 -0800
committerScott Shawcroft <scott@tannewt.org>2018-11-09 16:41:08 -0800
commit355abc835ea75715b4dea38604ef64f8c4eeaa0f (patch)
tree7e7c16e386157a42f686b27dbb6731738683befa /py
parent97bc95183d5114ce69c9387ebd2e2aa13feb65a7 (diff)
Fix output overflow and make help translatable
Diffstat (limited to 'py')
-rw-r--r--py/builtinhelp.c14
-rw-r--r--py/makeqstrdata.py3
2 files changed, 12 insertions, 5 deletions
diff --git a/py/builtinhelp.c b/py/builtinhelp.c
index 4cea7e6d5..9a3407a16 100644
--- a/py/builtinhelp.c
+++ b/py/builtinhelp.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
+#include "genhdr/mpversion.h"
#include "py/builtin.h"
#include "py/mpconfig.h"
#include "py/objmodule.h"
@@ -133,7 +134,10 @@ STATIC void mp_help_print_modules(void) {
}
// let the user know there may be other modules available from the filesystem
- mp_print_str(MP_PYTHON_PRINTER, "Plus any modules on the filesystem\n");
+ const compressed_string_t* compressed = translate("Plus any modules on the filesystem\n");
+ char decompressed[compressed->length];
+ decompress(compressed, decompressed);
+ mp_print_str(MP_PYTHON_PRINTER, decompressed);
}
#endif
@@ -174,8 +178,12 @@ STATIC void mp_help_print_obj(const mp_obj_t obj) {
STATIC mp_obj_t mp_builtin_help(size_t n_args, const mp_obj_t *args) {
if (n_args == 0) {
- // print a general help message
- mp_print_str(MP_PYTHON_PRINTER, MICROPY_PY_BUILTINS_HELP_TEXT);
+ // print a general help message. Translate only works on single strings on one line.
+ const compressed_string_t* compressed =
+ translate("Welcome to Adafruit CircuitPython %s!\n\nPlease visit learn.adafruit.com/category/circuitpython for project guides.\n\nTo list built-in modules please do `help(\"modules\")`.\n");
+ char decompressed[compressed->length];
+ decompress(compressed, decompressed);
+ mp_printf(MP_PYTHON_PRINTER, decompressed, MICROPY_GIT_TAG);
} else {
// try to print something sensible about the given object
mp_help_print_obj(args[0]);
diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py
index b0a043ee3..5b5ec1c37 100644
--- a/py/makeqstrdata.py
+++ b/py/makeqstrdata.py
@@ -349,8 +349,7 @@ def print_qstr_data(encoding_table, qcfgs, qstrs, i18ns):
total_text_compressed_size += len(compressed)
decompressed = decompress(encoding_table, len(translation_encoded), compressed).decode("utf-8")
for c in C_ESCAPES:
- decompressed.replace(c, C_ESCAPES[c])
- #print("// \"{}\"".format(translation))
+ decompressed = decompressed.replace(c, C_ESCAPES[c])
print("TRANSLATION(\"{}\", {}, {{ {} }}) // {}".format(original, len(translation_encoded)+1, ", ".join(["0x{:02x}".format(x) for x in compressed]), decompressed))
total_text_size += len(translation.encode("utf-8"))