diff --git a/src/Directory.cpp b/src/Directory.cpp index 9ae2d18ac..f99c36509 100644 --- a/src/Directory.cpp +++ b/src/Directory.cpp @@ -25,6 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include diff --git a/src/File.cpp b/src/File.cpp index 40c7de6ca..7a818f5dc 100644 --- a/src/File.cpp +++ b/src/File.cpp @@ -25,13 +25,17 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include #include #include #include +#include #include +#include //////////////////////////////////////////////////////////////////////////////// File::File () @@ -107,8 +111,7 @@ bool File::open () bool already_exists = exists (); if (already_exists) if (!readable () || !writable ()) - throw std::string ("Task does not have the correct permissions for '") + - data + "'."; + throw std::string (format (STRING_FILE_PERMS, data)); fh = fopen (data.c_str (), (already_exists ? "r+" : "w+")); if (fh) diff --git a/src/Path.cpp b/src/Path.cpp index 95e8031ef..09ccae7be 100644 --- a/src/Path.cpp +++ b/src/Path.cpp @@ -25,6 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include diff --git a/src/Timer.cpp b/src/Timer.cpp index ea6d127c6..224bb1e0c 100644 --- a/src/Timer.cpp +++ b/src/Timer.cpp @@ -24,6 +24,9 @@ // USA // //////////////////////////////////////////////////////////////////////////////// + +#define L10N // Localization complete. + #include #include #include diff --git a/src/en-US.h b/src/en-US.h index 025e18444..50471b51b 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -86,28 +86,6 @@ #ifndef INCLUDED_STRINGS #define INCLUDED_STRINGS -// Errors -#define STRING_UNKNOWN_ERROR "Unknown error." -#define STRING_NO_HOME "Could not read home directory from the passwd file." -#define STRING_TAGS_NO_COMMAS "Tags are not permitted to contain commas." -#define STRING_TRIVIAL_INPUT "You must specify a command, or a task ID to modify." -#define STRING_ASSUME_INFO "No command - assuming 'info'" - -// 'show' command -#define STRING_CMD_SHOW "Shows the entire task configuration variables or the ones containing substring." -#define STRING_CMD_SHOW_ARGS "You can only specify 'all' or a search string." -#define STRING_CMD_SHOW_NONE "No matching configuration variables." -#define STRING_CMD_SHOW_UNREC "Your .taskrc file contains these unrecognized variables:" -#define STRING_CMD_SHOW_DIFFER "Some of your .taskrc variables differ from the default values." -#define STRING_CMD_SHOW_HOOKS "Your .taskrc file contains these missing or unreadable hook scripts:" -#define STRING_CMD_SHOW_EMPTY "Configuration error: .taskrc contains no entries." -#define STRING_CMD_SHOW_DIFFER_COLOR "These are highlighted in {1} above." -#define STRING_CMD_SHOW_CONFIG_ERROR "Configuration error: {1} contains an unrecognized value '{2}'." -#define STRING_CMD_SHOW_NO_LOCATION "Configuration error: data.location not specified in .taskrc file." -#define STRING_CMD_SHOW_LOC_EXIST "Configuration error: data.location contains a directory name that doesn't exist, or is unreadable." -#define STRING_CMD_SHOW_CONF_VAR "Config Variable" -#define STRING_CMD_SHOW_CONF_VALUE "Value" - // API #define STRING_API_EXITING "Exiting." #define STRING_API_NOFUNC "The Lua function '{1}' was not found." @@ -129,9 +107,44 @@ #define STRING_DOM_UNREC "DOM: Cannot get unrecognized name '{1}'." #define STRING_DOM_CANNOT_SET "DOM: Cannot set '{1}'." +// Errors +// TODO Move each of these to appropriate section. +#define STRING_UNKNOWN_ERROR "Unknown error." +#define STRING_NO_HOME "Could not read home directory from the passwd file." +#define STRING_TAGS_NO_COMMAS "Tags are not permitted to contain commas." +#define STRING_TRIVIAL_INPUT "You must specify a command, or a task ID to modify." +#define STRING_ASSUME_INFO "No command - assuming 'info'" + +// File +#define STRING_FILE_PERMS "Task does not have the correct permissions for '{1}'." + // Lua #define STRING_LUA_BAD_HOOK_DEF "Malformed hook definition '{1}'." #define STRING_LUA_BAD_EVENT "Unrecognized hook event '{1}'." +// 'show' command +#define STRING_CMD_SHOW "Shows the entire task configuration variables or the ones containing substring." +#define STRING_CMD_SHOW_ARGS "You can only specify 'all' or a search string." +#define STRING_CMD_SHOW_NONE "No matching configuration variables." +#define STRING_CMD_SHOW_UNREC "Your .taskrc file contains these unrecognized variables:" +#define STRING_CMD_SHOW_DIFFER "Some of your .taskrc variables differ from the default values." +#define STRING_CMD_SHOW_HOOKS "Your .taskrc file contains these missing or unreadable hook scripts:" +#define STRING_CMD_SHOW_EMPTY "Configuration error: .taskrc contains no entries." +#define STRING_CMD_SHOW_DIFFER_COLOR "These are highlighted in {1} above." +#define STRING_CMD_SHOW_CONFIG_ERROR "Configuration error: {1} contains an unrecognized value '{2}'." +#define STRING_CMD_SHOW_NO_LOCATION "Configuration error: data.location not specified in .taskrc file." +#define STRING_CMD_SHOW_LOC_EXIST "Configuration error: data.location contains a directory name that doesn't exist, or is unreadable." +#define STRING_CMD_SHOW_CONF_VAR "Config Variable" +#define STRING_CMD_SHOW_CONF_VALUE "Value" + +// text + // A comma-separated list of commands is appended. +#define STRING_TEXT_AMBIGUOUS "Ambiguous {1} '{2}' - could be either of " + +// utf8 +#define STRING_UTF8_INVALID_CP_REP "Invalid codepoint representation." +#define STRING_UTF8_INVALID_CP "Invalid Unicode codepoint." + + #endif diff --git a/src/interactive.cpp b/src/interactive.cpp index f54b6f5b1..6a6a01582 100644 --- a/src/interactive.cpp +++ b/src/interactive.cpp @@ -25,11 +25,14 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include #include #include +#include #include #include @@ -58,9 +61,7 @@ int Context::getWidth () terminal_height = buff[0]; terminal_width = buff[1]; - std::stringstream out; - out << "Context::getWidth: determined width of " << terminal_width << " characters"; - debug (out.str ()); + debug (format ("Context::getWidth: determined width of {1} characters", terminal_width)); } } @@ -92,9 +93,7 @@ int Context::getHeight () terminal_height = buff[0]; terminal_width = buff[1]; - std::stringstream out; - out << "Context::getWidth: determined height of " << terminal_height << " characters"; - debug (out.str ()); + debug (format ("Context::getHeight: determined height of {1} characters", terminal_height)); } } diff --git a/src/main.cpp b/src/main.cpp index 1db9dbb00..a2b1656af 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,6 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include diff --git a/src/sort.cpp b/src/sort.cpp index d97fd17c3..4277584f7 100644 --- a/src/sort.cpp +++ b/src/sort.cpp @@ -25,7 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// -#include // TODO Remove +#define L10N // Localization complete. + #include #include #include diff --git a/src/text.cpp b/src/text.cpp index df2d56ae4..b2f4e9e81 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -25,6 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include @@ -37,6 +39,7 @@ #include #include #include +#include extern Context context; @@ -494,11 +497,7 @@ void guess ( { std::sort (matches.begin (), matches.end ()); - std::string error = "Ambiguous "; // TODO i18n - error += type; - error += " '"; - error += candidate; - error += "' - could be either of "; // TODO i18n + std::string error = format (STRING_TEXT_AMBIGUOUS, type, candidate); for (size_t i = 0; i < matches.size (); ++i) { if (i) diff --git a/src/text.h b/src/text.h index bd38556f2..556244856 100644 --- a/src/text.h +++ b/src/text.h @@ -76,7 +76,7 @@ const std::string format (const std::string&, const std::string&); const std::string format (const std::string&, int); const std::string format (const std::string&, const std::string&, const std::string&); const std::string format (const std::string&, const std::string&, int); -const std::string format (const std::string&, int, const std::string& arg2); +const std::string format (const std::string&, int, const std::string&); const std::string format (const std::string&, int, int); const std::string format (const std::string&, const std::string&, const std::string&, const std::string&); diff --git a/src/utf8.cpp b/src/utf8.cpp index 2cd81d60a..b711150e2 100644 --- a/src/utf8.cpp +++ b/src/utf8.cpp @@ -25,8 +25,11 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include +#include //////////////////////////////////////////////////////////////////////////////// // Converts '0' -> 0 @@ -65,7 +68,7 @@ unsigned int utf8_codepoint (const std::string& input) XDIGIT (input[3]); } else - throw std::string ("Invalid codepoint representation."); + throw std::string (STRING_UTF8_INVALID_CP_REP); return codepoint; } @@ -144,7 +147,7 @@ std::string utf8_character (unsigned int codepoint) sequence[4] = 0; } else - throw std::string ("Invalid Unicode codepoint."); + throw std::string (STRING_UTF8_INVALID_CP); sequence[4] = '\0'; return std::string (sequence);