From 96ebf5bc3fb455162286b9bc31e763f3c4f1c457 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 8 Aug 2018 18:24:49 -0700 Subject: Two fixes and translate more strings. * Fix finding translations with escaped characters. * Add back \r to translations since its needed by screen. --- py/parse.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'py/parse.c') diff --git a/py/parse.c b/py/parse.c index f915f7598..911b891e0 100644 --- a/py/parse.c +++ b/py/parse.c @@ -39,6 +39,8 @@ #include "py/objstr.h" #include "py/builtin.h" +#include "supervisor/shared/translate.h" + #if MICROPY_ENABLE_COMPILER #define RULE_ACT_ARG_MASK (0x0f) @@ -721,7 +723,7 @@ STATIC bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) { mp_obj_t value; if (!mp_parse_node_get_int_maybe(pn_value, &value)) { mp_obj_t exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, - "constant must be an integer"); + translate("constant must be an integer")); mp_obj_exception_add_traceback(exc, parser->lexer->source_name, ((mp_parse_node_struct_t*)pn1)->source_line, MP_QSTR_NULL); nlr_raise(exc); @@ -863,7 +865,7 @@ mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) { } } if (parser.rule_stack == NULL || parser.result_stack == NULL) { - mp_raise_msg(&mp_type_MemoryError, "Unable to init parser"); + mp_raise_msg(&mp_type_MemoryError, translate("Unable to init parser")); } parser.lexer = lex; @@ -1165,13 +1167,13 @@ mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) { mp_obj_t exc; if (lex->tok_kind == MP_TOKEN_INDENT) { exc = mp_obj_new_exception_msg(&mp_type_IndentationError, - "unexpected indent"); + translate("unexpected indent")); } else if (lex->tok_kind == MP_TOKEN_DEDENT_MISMATCH) { exc = mp_obj_new_exception_msg(&mp_type_IndentationError, - "unindent does not match any outer indentation level"); + translate("unindent does not match any outer indentation level")); } else { exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, - "invalid syntax"); + translate("invalid syntax")); } // add traceback to give info about file name and location // we don't have a 'block' name, so just pass the NULL qstr to indicate this -- cgit v1.2.3