Skip to content

Commit 1407af7

Browse files
committed
Add localization for built-in help
Support localizing the output of a call to to match the firmware's language.
1 parent 72cad49 commit 1407af7

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

locale/circuitpython.pot

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2020-12-23 23:04-0500\n"
11+
"POT-Creation-Date: 2020-12-30 17:42-0600\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -44,6 +44,10 @@ msgstr ""
4444
msgid " File \"%q\", line %d"
4545
msgstr ""
4646

47+
#: py/builtinhelp.c
48+
msgid " is of type %q\n"
49+
msgstr ""
50+
4751
#: main.c
4852
msgid " output:\n"
4953
msgstr ""
@@ -3193,6 +3197,10 @@ msgstr ""
31933197
msgid "number of points must be at least 2"
31943198
msgstr ""
31953199

3200+
#: py/builtinhelp.c
3201+
msgid "object "
3202+
msgstr ""
3203+
31963204
#: py/obj.c
31973205
msgid "object '%q' is not a tuple or list"
31983206
msgstr ""

py/builtinhelp.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,18 @@ STATIC void mp_help_print_obj(const mp_obj_t obj) {
152152
mp_obj_type_t *type = mp_obj_get_type(obj);
153153

154154
// try to print something sensible about the given object
155-
mp_print_str(MP_PYTHON_PRINTER, "object ");
155+
const compressed_string_t* compressed = translate("object ");
156+
char decompressed_object[decompress_length(compressed)];
157+
decompress(compressed, decompressed_object);
158+
159+
mp_print_str(MP_PYTHON_PRINTER, decompressed_object);
156160
mp_obj_print(obj, PRINT_STR);
157-
mp_printf(MP_PYTHON_PRINTER, " is of type %q\n", type->name);
161+
162+
compressed = translate(" is of type %q\n");
163+
char decompressed_typestring[decompress_length(compressed)];
164+
decompress(compressed, decompressed_typestring);
165+
166+
mp_printf(MP_PYTHON_PRINTER, decompressed_typestring, type->name);
158167

159168
mp_map_t *map = NULL;
160169
if (type == &mp_type_module) {

0 commit comments

Comments
 (0)