diff --git a/src/Config.cpp b/src/Config.cpp index 1be5d1be9..fede784fe 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -24,6 +24,9 @@ // USA // //////////////////////////////////////////////////////////////////////////////// + +#define L10N // Localization complete. + #include #include #include @@ -542,13 +545,13 @@ void Config::parse (const std::string& input, int nest /* = 1 */) if (included.readable ()) this->load (included, nest + 1); else - throw std::string ("Could not read include file '") + included.data + "'."; + throw format (STRING_CONFIG_READ_INCLUDE, included.data); } else - throw std::string ("Can only include files with absolute paths, not '") + included.data + "'"; + throw format (STRING_CONFIG_INCLUDE_PATH, included.data); } else - throw std::string ("Malformed entry '") + line + "'."; + throw format (STRING_CONFIG_BAD_ENTRY, line); } } } @@ -585,7 +588,7 @@ void Config::createDefaultRC (const std::string& rc, const std::string& data) // Write out the new file. if (! File::write (rc, contents.str ())) - throw std::string ("Could not write to '") + rc + "'."; + throw format (STRING_CONFIG_BAD_WRITE, rc); } //////////////////////////////////////////////////////////////////////////////// @@ -699,8 +702,8 @@ std::string Config::checkForDeprecatedColor () std::stringstream out; if (deprecated.size ()) { - out << "Your .taskrc file contains color settings that use deprecated " - << "underscores. Please check:\n"; + out << STRING_CONFIG_DEPRECATED_US + << "\n"; std::vector ::iterator it2; for (it2 = deprecated.begin (); it2 != deprecated.end (); ++it2) @@ -734,8 +737,8 @@ std::string Config::checkForDeprecatedColumns () if (deprecated.size ()) { - out << "Your .taskrc file contains reports with deprecated columns. " - << "Please check for entry_time, start_time or end_time in:\n"; + out << STRING_CONFIG_DEPRECATED_COL + << "\n"; std::vector ::iterator it2; for (it2 = deprecated.begin (); it2 != deprecated.end (); ++it2) diff --git a/src/Duration.cpp b/src/Duration.cpp index f52b4c6fd..31601cbff 100644 --- a/src/Duration.cpp +++ b/src/Duration.cpp @@ -25,6 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include @@ -33,6 +35,7 @@ #include #include #include +#include #include static const char* durations[] = @@ -369,7 +372,7 @@ void Duration::parse (const std::string& input) } if (mSecs == 0) - throw std::string ("The duration '") + input + "' was not recognized."; + throw ::format (STRING_DURATION_UNRECOGNIZED, input); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 5e5c93a16..8f8a49af7 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -25,6 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include @@ -33,8 +35,6 @@ #include #include -#define L10N // Localization complete. - extern Context context; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/JSON.cpp b/src/JSON.cpp index e9f57cff6..57e7bf477 100644 --- a/src/JSON.cpp +++ b/src/JSON.cpp @@ -25,8 +25,10 @@ // //////////////////////////////////////////////////////////////////////////////// -#include // TODO Remove. +#define L10N // Localization complete. + #include +#include #include #include @@ -198,8 +200,7 @@ json::array* json::array::parse (Nibbler& nibbler) else { delete arr; - throw std::string ("Error: missing value after ',' at position ") + - format ((int) n.cursor ()); + throw format (STRING_JSON_MISSING_VALUE, (int) n.cursor ()); } } } @@ -210,8 +211,7 @@ json::array* json::array::parse (Nibbler& nibbler) return arr; } else - throw std::string ("Error: missing ']' at position ") + - format ((int) n.cursor ()); + throw format (STRING_JSON_MISSING_BRACKET, (int) n.cursor ()); delete arr; } @@ -287,8 +287,7 @@ json::object* json::object::parse (Nibbler& nibbler) else { delete obj; - throw std::string ("Error: missing value after ',' at position ") + - format ((int) n.cursor ()); + throw format (STRING_JSON_MISSING_VALUE, (int) n.cursor ()); } } } @@ -299,8 +298,7 @@ json::object* json::object::parse (Nibbler& nibbler) return obj; } else - throw std::string ("Error: missing '}' at position ") + - format ((int) n.cursor ()); + throw format (STRING_JSON_MISSING_BRACE, (int) n.cursor ()); delete obj; } @@ -328,12 +326,10 @@ bool json::object::parse_pair ( return true; } else - throw std::string ("Error: missing value at position ") + - format ((int) n.cursor ()); + throw format (STRING_JSON_MISSING_VALUE2, (int) n.cursor ()); } else - throw std::string ("Error: missing ':' at position ") + - format ((int) n.cursor ()); + throw format (STRING_JSON_MISSING_COLON, (int) n.cursor ()); } return NULL; @@ -378,16 +374,14 @@ json::value* json::parse (const std::string& input) if (n.next () == '{') root = json::object::parse (n); else if (n.next () == '[') root = json::array::parse (n); else - throw std::string ("Error: expected '{' or '[' at position ") + - format ((int)n.cursor ()); + throw format (STRING_JSON_MISSING_OPEN, (int) n.cursor ()); // Check for end condition. n.skipWS (); if (!n.depleted ()) { delete root; - throw std::string ("Error: extra characters found at position ") + - format ((int) n.cursor ()); + throw format (STRING_JSON_EXTRA_CHARACTERS, (int) n.cursor ()); } return root; diff --git a/src/Permission.cpp b/src/Permission.cpp index 181002e10..10f2026c6 100644 --- a/src/Permission.cpp +++ b/src/Permission.cpp @@ -25,6 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include @@ -32,8 +34,6 @@ #include #include -#define L10N // Localization complete. - extern Context context; //////////////////////////////////////////////////////////////////////////////// diff --git a/src/RX.cpp b/src/RX.cpp index 967ac3ac2..4d8f2fc2b 100644 --- a/src/RX.cpp +++ b/src/RX.cpp @@ -25,12 +25,12 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include -#define L10N // Localization complete. - //#define _POSIX_C_SOURCE 1 // Forgot why this is here. Moving on... //////////////////////////////////////////////////////////////////////////////// diff --git a/src/dependency.cpp b/src/dependency.cpp index 5d8f95810..d482fcfa3 100644 --- a/src/dependency.cpp +++ b/src/dependency.cpp @@ -25,12 +25,15 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include #include #include #include +#include #include extern Context context; @@ -200,7 +203,9 @@ void dependencyChainOnComplete (Task& task) // Nag about broken chain. if (context.config.getBoolean ("dependency.reminder")) { - std::cout << "Task " << task.id << " is blocked by:\n"; + std::cout << format (STRING_DEPEND_BLOCKED, task.id) + << "\n"; + std::vector ::iterator b; for (b = blocking.begin (); b != blocking.end (); ++b) std::cout << " " << b->id << " " << b->get ("description") << "\n"; @@ -211,14 +216,16 @@ void dependencyChainOnComplete (Task& task) { if (context.config.getBoolean ("dependency.reminder")) { - std::cout << "and is blocking:\n"; + std::cout << STRING_DEPEND_BLOCKING + << "\n"; + std::vector ::iterator b; for (b = blocked.begin (); b != blocked.end (); ++b) std::cout << " " << b->id << " " << b->get ("description") << "\n"; } if (!context.config.getBoolean ("dependency.confirmation") || - confirm ("Would you like the dependency chain fixed?")) + confirm (STRING_DEPEND_FIX_CHAIN)) { // Repair the chain - everything in blocked should now depend on // everything in blocking, instead of task.id. @@ -255,7 +262,9 @@ void dependencyChainOnStart (Task& task) // broken chain. if (blocking.size ()) { - std::cout << "Task " << task.id << " is blocked by:\n"; + std::cout << format (STRING_DEPEND_BLOCKED, task.id) + << "\n"; + std::vector ::iterator b; for (b = blocking.begin (); b != blocking.end (); ++b) std::cout << " " << b->id << " " << b->get ("description") << "\n"; diff --git a/src/en-US.h b/src/en-US.h index f2bba4bbe..c04adbd86 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -217,16 +217,30 @@ // Config #define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake." +#define STRING_CONFIG_READ_INCLUDE "Could not read include file '{1}'." +#define STRING_CONFIG_INCLUDE_PATH "Can only include files with absolute paths, not '{1}'" +#define STRING_CONFIG_BAD_ENTRY "Malformed entry '{1}'." +#define STRING_CONFIG_BAD_WRITE "Could not write to '{1}'." +#define STRING_CONFIG_DEPRECATED_US "Your .taskrc file contains color settings that use deprecated underscores. Please check:" +#define STRING_CONFIG_DEPRECATED_COL "Your .taskrc file contains reports with deprecated columns. Please check for entry_time, start_time or end_time in:" // Context #define STRING_CONTEXT_CREATE_RC "A configuration file could not be found in {1}\n\nWould you like a sample {2} created, so taskwarrior can proceed?" #define STRING_CONTEXT_NEED_RC "Cannot proceed without rc file." +// dependency +#define STRING_DEPEND_BLOCKED "Task {1} is blocked by:" +#define STRING_DEPEND_BLOCKING "and is blocking:" +#define STRING_DEPEND_FIX_CHAIN "Would you like the dependency chain fixed?" + // DOM #define STRING_DOM_UNKNOWN "" #define STRING_DOM_UNREC "DOM: Cannot get unrecognized name '{1}'." #define STRING_DOM_CANNOT_SET "DOM: Cannot set '{1}'." +// Duration +#define STRING_DURATION_UNRECOGNIZED "The duration '{1}' was not recognized." + // Errors // TODO Move each of these to appropriate section. #define STRING_UNKNOWN_ERROR "Unknown error." @@ -248,6 +262,15 @@ #define STRING_INTERACTIVE_WIDTH "Context::getWidth: determined width of {1} characters" #define STRING_INTERACTIVE_HEIGHT "Context::getHeight: determined height of {1} characters" +// JSON +#define STRING_JSON_MISSING_VALUE "Error: missing value after ',' at position {1}" +#define STRING_JSON_MISSING_VALUE2 "Error: missing value at position {1}" +#define STRING_JSON_MISSING_BRACKET "Error: missing ']' at position {1}" +#define STRING_JSON_MISSING_BRACE "Error: missing '}' at position {1}" +#define STRING_JSON_MISSING_COLON "Error: missing ':' at position {1}" +#define STRING_JSON_MISSING_OPEN "Error: expected '{' or '[' at position {1}" +#define STRING_JSON_EXTRA_CHARACTERS "Error: extra characters found at position {1}" + // Lua #define STRING_LUA_BAD_HOOK_DEF "Malformed hook definition '{1}'." #define STRING_LUA_BAD_EVENT "Unrecognized hook event '{1}'." diff --git a/src/rules.cpp b/src/rules.cpp index 9de2de8bd..e9ba71410 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -24,6 +24,9 @@ // USA // //////////////////////////////////////////////////////////////////////////////// + +#define L10N // Localization complete. + #include #include #include @@ -32,8 +35,6 @@ #include #include -#define L10N // Localization complete. - extern Context context; static std::map gsColor; @@ -318,4 +319,3 @@ std::string colorizeDebug (const std::string& input) } //////////////////////////////////////////////////////////////////////////////// -