From 1407af72913d891eefe884ff65f42f6b55aa2a14 Mon Sep 17 00:00:00 2001 From: Hugo Dahl Date: Wed, 30 Dec 2020 17:47:35 -0600 Subject: Add localization for built-in help Support localizing the output of a call to to match the firmware's language. --- py/builtinhelp.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'py/builtinhelp.c') diff --git a/py/builtinhelp.c b/py/builtinhelp.c index d12e088d6..e1dcb6096 100644 --- a/py/builtinhelp.c +++ b/py/builtinhelp.c @@ -152,9 +152,18 @@ STATIC void mp_help_print_obj(const mp_obj_t obj) { mp_obj_type_t *type = mp_obj_get_type(obj); // try to print something sensible about the given object - mp_print_str(MP_PYTHON_PRINTER, "object "); + const compressed_string_t* compressed = translate("object "); + char decompressed_object[decompress_length(compressed)]; + decompress(compressed, decompressed_object); + + mp_print_str(MP_PYTHON_PRINTER, decompressed_object); mp_obj_print(obj, PRINT_STR); - mp_printf(MP_PYTHON_PRINTER, " is of type %q\n", type->name); + + compressed = translate(" is of type %q\n"); + char decompressed_typestring[decompress_length(compressed)]; + decompress(compressed, decompressed_typestring); + + mp_printf(MP_PYTHON_PRINTER, decompressed_typestring, type->name); mp_map_t *map = NULL; if (type == &mp_type_module) { -- cgit v1.2.3