From 81ca87b7da26710ef41116355463f27b41d0c8a8 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 1 Oct 2011 13:13:30 -0400 Subject: [PATCH] I18N - Localized E9. --- src/E9.cpp | 11 +++++++---- src/en-US.h | 6 ++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/E9.cpp b/src/E9.cpp index 6692ceb58..007b2c10b 100644 --- a/src/E9.cpp +++ b/src/E9.cpp @@ -25,11 +25,14 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include #include #include +#include #include #include @@ -103,7 +106,7 @@ void E9::eval (const Task& task, std::vector & value_stack) if (arg->_raw == "!") { if (value_stack.size () < 1) - throw std::string ("There are no operands for the 'not' operator."); + throw format (STRING_E9_NO_OPERANDS, "not"); Arg right = value_stack.back (); value_stack.pop_back (); @@ -124,7 +127,7 @@ void E9::eval (const Task& task, std::vector & value_stack) else { if (value_stack.size () < 2) - throw std::string ("There are not enough operands for the '") + arg->_raw + "' operator."; + throw format (STRING_E9_INSUFFICIENT_OP, arg->_raw); Arg right = value_stack.back (); value_stack.pop_back (); @@ -148,7 +151,7 @@ void E9::eval (const Task& task, std::vector & value_stack) else if (arg->_raw == "+") operator_add (result, left, right); else if (arg->_raw == "-") operator_subtract (result, left, right); else - throw std::string ("Unsupported operator '") + arg->_raw + "'."; + throw format (STRING_E9_UNSUPPORTED, arg->_raw); } // Store the result. @@ -188,7 +191,7 @@ void E9::eval (const Task& task, std::vector & value_stack) // Check for stack remnants. if (value_stack.size () != 1) - throw std::string ("Error: Expression::eval found extra items on the stack."); + throw std::string (STRING_E9_MORE_OP); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/en-US.h b/src/en-US.h index 734bedd3d..8c8cff380 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -451,6 +451,12 @@ // Duration #define STRING_DURATION_UNRECOGNIZED "The duration '{1}' was not recognized." +// E9 +#define STRING_E9_UNSUPPORTED "Unsupported operator '{1}'." +#define STRING_E9_NO_OPERANDS "There are no operands for the '{1}' operator." +#define STRING_E9_INSUFFICIENT_OP "There are not enough operands for the '{1}' operator." +#define STRING_E9_MORE_OP "Found extra operands." + // Errors // TODO Move each of these to appropriate section. #define STRING_UNKNOWN_ERROR "Unknown error."