From 376c79ef6fa20de3549e078d0e70a828f9ab86af Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 26 Sep 2011 22:39:08 -0400 Subject: [PATCH] I18N - Localized the 'config' command. --- src/commands/CmdConfig.cpp | 33 +++++++++++++++------------------ src/en-US.h | 10 ++++++++++ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/commands/CmdConfig.cpp b/src/commands/CmdConfig.cpp index cc4966fd2..c6a594aa1 100644 --- a/src/commands/CmdConfig.cpp +++ b/src/commands/CmdConfig.cpp @@ -25,9 +25,12 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include +#include #include #include #include @@ -39,7 +42,7 @@ CmdConfig::CmdConfig () { _keyword = "config"; _usage = "task config [name [value | '']]"; - _description = "Add, modify and remove settings in the task configuration."; + _description = STRING_CMD_CONFIG_USAGE; _read_only = true; _displays_id = false; } @@ -98,12 +101,7 @@ int CmdConfig::execute (std::string& output) comment > pos)) { found = true; - if (confirm (std::string ("Are you sure you want to change the value of '") - + name - + "' from '" - + context.config.get(name) - + "' to '" - + value + "'?")) + if (confirm (format (STRING_CMD_CONFIG_CONFIRM, name, context.config.get (name), value))) { if (comment != std::string::npos) *line = name + "=" + value + " " + line->substr (comment); @@ -117,7 +115,7 @@ int CmdConfig::execute (std::string& output) // Not found, so append instead. if (!found && - confirm (std::string ("Are you sure you want to add '") + name + "' with a value of '" + value + "'?")) + confirm (format (STRING_CMD_CONFIG_CONFIRM2, name, value))) { contents.push_back (name + "=" + value); change = true; @@ -142,7 +140,7 @@ int CmdConfig::execute (std::string& output) found = true; // Remove name - if (confirm (std::string ("Are you sure you want to remove '") + name + "'?")) + if (confirm (format (STRING_CMD_CONFIG_CONFIRM3, name))) { *line = ""; change = true; @@ -151,27 +149,27 @@ int CmdConfig::execute (std::string& output) } if (!found) - throw std::string ("No entry named '") + name + "' found."; + throw format (STRING_CMD_CONFIG_NO_ENTRY, name); } // Write .taskrc (or equivalent) if (change) { File::write (context.config._original_file, contents); - out << "Config file " - << context.config._original_file._data - << " modified.\n"; + out << format (STRING_CMD_CONFIG_FILE_MOD, + context.config._original_file._data) + << "\n"; } else - out << "No changes made.\n"; + out << STRING_CMD_CONFIG_NO_CHANGE << "\n"; } else - throw std::string ("Specify the name of a config variable to modify."); + throw std::string (STRING_CMD_CONFIG_NO_NAME); output = out.str (); } else - throw std::string ("Specify the name of a config variable to modify."); + throw std::string (STRING_CMD_CONFIG_NO_NAME); return rc; } @@ -181,8 +179,7 @@ CmdCompletionConfig::CmdCompletionConfig () { _keyword = "_config"; _usage = "task _config"; - _description = "Lists all supported configuration variables, for completion " - "purposes."; + _description = STRING_CMD_HCONFIG_USAGE; _read_only = true; _displays_id = false; } diff --git a/src/en-US.h b/src/en-US.h index 47157e9b8..ac869ad6a 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -369,6 +369,16 @@ #define STRING_CMD_COLOR_RAMP "Gray ramp" #define STRING_CMD_COLOR_TRY "Try running '{1}'." #define STRING_CMD_COLOR_OFF "Color is currently turned off in your .taskrc file. To enable color, remove the line 'color=off', or change the 'off' to 'on'." +#define STRING_CMD_CONFIG_USAGE "Add, modify and remove settings in the task configuration." +#define STRING_CMD_CONFIG_CONFIRM "Are you sure you want to change the value of '{1}' from '{2}' to '{3}'?" +#define STRING_CMD_CONFIG_CONFIRM2 "Are you sure you want to add '{1}' with a value of '{2}'?" +#define STRING_CMD_CONFIG_CONFIRM3 "Are you sure you want to remove '{1}'?" +#define STRING_CMD_CONFIG_NO_ENTRY "No entry named '{1}' found." +#define STRING_CMD_CONFIG_FILE_MOD "Config file {1} modified." +#define STRING_CMD_CONFIG_NO_CHANGE "No changes made." +#define STRING_CMD_CONFIG_NO_NAME "Specify the name of a config variable to modify." + +#define STRING_CMD_HCONFIG_USAGE "Lists all supported configuration variables, for completion purposes." // Config #define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake."