diff options
author | Marion <marion.zepf@gmail.com> | 2013-08-01 16:43:45 (GMT) |
---|---|---|
committer | Marion <marion.zepf@gmail.com> | 2013-08-01 16:43:45 (GMT) |
commit | 0942aecc5b6dcb4d4ba1e5de926a0943da25cc06 (patch) | |
tree | fecea6d29847c912f3eb115c63d7599348a497cc /TurtleArt | |
parent | 555063f706111aaae91fe0e2714feab88c608463 (diff) |
enable i18n for the new error messages
Diffstat (limited to 'TurtleArt')
-rw-r--r-- | TurtleArt/taexportpython.py | 6 | ||||
-rw-r--r-- | TurtleArt/taprimitive.py | 12 |
2 files changed, 10 insertions, 8 deletions
diff --git a/TurtleArt/taexportpython.py b/TurtleArt/taexportpython.py index 4688ea9..78a6592 100644 --- a/TurtleArt/taexportpython.py +++ b/TurtleArt/taexportpython.py @@ -21,6 +21,7 @@ """ Python export tool """ import ast +from gettext import gettext as _ from os import linesep import re import util.codegen as codegen @@ -131,12 +132,13 @@ def _walk_action_stack(top_block, lc): prim = lc.get_prim_callable(block.primitive) # fail gracefully if primitive is not a Primitive object if not isinstance(prim, Primitive): - raise PyExportError("block is not exportable", block=block) + raise PyExportError(_("block is not exportable"), block=block) if prim.export_me: try: new_ast = prim.get_ast(*arg_asts) except ValueError: - raise PyExportError("error while exporting block", block=block) + raise PyExportError(_("error while exporting block"), + block=block) if isinstance(new_ast, (list, tuple)): ast_list.extend(new_ast) else: diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py index 3d1feb3..b2d6683 100644 --- a/TurtleArt/taprimitive.py +++ b/TurtleArt/taprimitive.py @@ -267,18 +267,18 @@ class Primitive(object): pos_value = new_arg_asts[0].n return ast.Num(n=-pos_value) else: - raise PyExportError("minus sign (float.__neg__) got unexpected" - " arguments: " + repr(new_arg_asts) + - repr(new_kwarg_asts)) + raise ValueError("minus sign (float.__neg__) got unexpected" + " arguments: " + repr(new_arg_asts) + + repr(new_kwarg_asts)) # tuples elif self == Primitive.make_tuple: if not new_kwarg_asts: return ast.Tuple(elts=new_arg_asts, ctx=ast.Load) else: - raise PyExportError("tuple constructor (Primitive.make_tuple) " - "got unexpected arguments: " + - repr(new_kwarg_asts)) + raise ValueError("tuple constructor (Primitive.make_tuple) " + "got unexpected arguments: " + + repr(new_kwarg_asts)) # group of Primitives elif self == Primitive.group: |