- Localized CmdShow.cpp.
This commit is contained in:
Paul Beckingham
2011-05-26 22:20:35 -04:00
parent 0caea22f08
commit 3de1275afe
2 changed files with 56 additions and 55 deletions

View File

@@ -54,10 +54,7 @@ int CmdShow::execute (const std::string& command_line, std::string& output)
// Obtain the arguments from the description. That way, things like '--' // Obtain the arguments from the description. That way, things like '--'
// have already been handled. // have already been handled.
std::vector <std::string> args; if (context.args.size () > 2)
split (args, context.task.get ("description"), ' ');
if (args.size () > 1)
throw std::string (STRING_CMD_SHOW_ARGS); throw std::string (STRING_CMD_SHOW_ARGS);
int width = context.getWidth (); int width = context.getWidth ();
@@ -68,12 +65,13 @@ int CmdShow::execute (const std::string& command_line, std::string& output)
// search for whole words. // search for whole words.
std::string recognized = std::string recognized =
" annotations bulk burndown.bias calendar.details calendar.details.report " " annotations bulk burndown.bias calendar.details calendar.details.report "
"calendar.holidays calendar.legend color calendar.offset calendar.offset.value " "calendar.holidays calendar.legend color calendar.offset "
"color.active color.due color.due.today color.blocked color.burndown.done " "calendar.offset.value color.active color.due color.due.today "
"color.burndown.pending color.burndown.started color.overdue color.pri.H " "color.blocked color.burndown.done color.burndown.pending "
"color.pri.L color.pri.M color.pri.none color.recurring color.tagged " "color.burndown.started color.overdue color.pri.H color.pri.L color.pri.M "
"color.footnote color.header color.debug color.alternate color.calendar.today " "color.pri.none color.recurring color.tagged color.footnote color.header "
"color.calendar.due color.calendar.due.today color.calendar.overdue regex " "color.debug color.alternate color.calendar.today color.calendar.due "
"color.calendar.due.today color.calendar.overdue regex "
"color.calendar.weekend color.calendar.holiday color.calendar.weeknumber " "color.calendar.weekend color.calendar.holiday color.calendar.weeknumber "
"color.summary.background color.summary.bar color.history.add " "color.summary.background color.summary.bar color.history.add "
"color.history.done color.history.delete color.undo.before color.label " "color.history.done color.history.delete color.undo.before color.label "
@@ -81,17 +79,17 @@ int CmdShow::execute (const std::string& command_line, std::string& output)
"confirmation data.location dateformat dateformat.holiday " "confirmation data.location dateformat dateformat.holiday "
"dateformat.report dateformat.annotation debug default.command default.due " "dateformat.report dateformat.annotation debug default.command default.due "
"default.priority default.project defaultwidth dependency.indicator due " "default.priority default.project defaultwidth dependency.indicator due "
"dependency.confirmation dependency.reminder detection locale displayweeknumber " "dependency.confirmation dependency.reminder detection locale "
"export.ical.class echo.command fontunderline gc locking monthsperline " "displayweeknumber export.ical.class echo.command fontunderline gc locking "
"nag journal.time journal.time.start.annotation journal.info " "monthsperline nag journal.time journal.time.start.annotation journal.info "
"journal.time.stop.annotation project shadow.command shadow.file " "journal.time.stop.annotation project shadow.command shadow.file "
"shadow.notify weekstart editor edit.verbose import.synonym.id import.synonym.uuid " "shadow.notify weekstart editor edit.verbose import.synonym.id "
"complete.all.projects complete.all.tags search.case.sensitive extensions " "import.synonym.uuid complete.all.projects complete.all.tags "
"active.indicator tag.indicator recurrence.indicator recurrence.limit " "search.case.sensitive extensions active.indicator tag.indicator "
"list.all.projects list.all.tags undo.style verbose rule.precedence.color " "recurrence.indicator recurrence.limit list.all.projects list.all.tags "
"merge.autopush merge.default.uri pull.default.uri push.default.uri " "undo.style verbose rule.precedence.color merge.autopush merge.default.uri "
"xterm.title shell.prompt indent.annotation indent.report column.spacing " "pull.default.uri push.default.uri xterm.title shell.prompt "
"row.padding column.padding " "indent.annotation indent.report column.spacing row.padding column.padding "
"import.synonym.status import.synonym.tags import.synonym.entry " "import.synonym.status import.synonym.tags import.synonym.entry "
"import.synonym.start import.synonym.due import.synonym.recur " "import.synonym.start import.synonym.due import.synonym.recur "
"import.synonym.end import.synonym.project import.synonym.priority " "import.synonym.end import.synonym.project import.synonym.priority "
@@ -157,8 +155,8 @@ int CmdShow::execute (const std::string& command_line, std::string& output)
std::string section; std::string section;
if (args.size () == 2) if (context.args.size () == 2)
section = args[1]; section = context.args[1];
if (section == "all") if (section == "all")
section = ""; section = "";
@@ -195,7 +193,7 @@ int CmdShow::execute (const std::string& command_line, std::string& output)
out << " " << *i << "\n"; out << " " << *i << "\n";
if (context.color ()) if (context.color ())
out << "\n These are highlighted in " << error.colorize ("color") << " above."; out << "\n " << format (STRING_CMD_SHOW_DIFFER_COLOR, error.colorize ("color"));
out << "\n\n"; out << "\n\n";
} }
@@ -205,7 +203,7 @@ int CmdShow::execute (const std::string& command_line, std::string& output)
out << STRING_CMD_SHOW_DIFFER; out << STRING_CMD_SHOW_DIFFER;
if (context.color ()) if (context.color ())
out << " These are highlighted in " << warning.colorize ("color") << " above."; out << " " << format (STRING_CMD_SHOW_DIFFER_COLOR, warning.colorize ("color"));
} }
out << context.config.checkForDeprecatedColor (); out << context.config.checkForDeprecatedColor ();
@@ -259,27 +257,24 @@ int CmdShow::execute (const std::string& command_line, std::string& output)
if (annotations != "full" && if (annotations != "full" &&
annotations != "sparse" && annotations != "sparse" &&
annotations != "none") annotations != "none")
out << "Configuration error: annotations contains an unrecognized value '" out << format (STRING_CMD_SHOW_CONFIG_ERROR, "annotations", annotations)
<< annotations << "\n";
<< "'.\n";
// Check for bad values in rc.calendar.details. // Check for bad values in rc.calendar.details.
std::string calendardetails = context.config.get ("calendar.details"); std::string calendardetails = context.config.get ("calendar.details");
if (calendardetails != "full" && if (calendardetails != "full" &&
calendardetails != "sparse" && calendardetails != "sparse" &&
calendardetails != "none") calendardetails != "none")
out << "Configuration error: calendar.details contains an unrecognized value '" out << format (STRING_CMD_SHOW_CONFIG_ERROR, "calendar.details", calendardetails)
<< calendardetails << "\n";
<< "'.\n";
// Check for bad values in rc.calendar.holidays. // Check for bad values in rc.calendar.holidays.
std::string calendarholidays = context.config.get ("calendar.holidays"); std::string calendarholidays = context.config.get ("calendar.holidays");
if (calendarholidays != "full" && if (calendarholidays != "full" &&
calendarholidays != "sparse" && calendarholidays != "sparse" &&
calendarholidays != "none") calendarholidays != "none")
out << "Configuration error: calendar.holidays contains an unrecognized value '" out << format (STRING_CMD_SHOW_CONFIG_ERROR, "calendar.holidays", calendarholidays)
<< calendarholidays << "\n";
<< "'.\n";
// Check for bad values in rc.default.priority. // Check for bad values in rc.default.priority.
std::string defaultPriority = context.config.get ("default.priority"); std::string defaultPriority = context.config.get ("default.priority");
@@ -287,9 +282,8 @@ int CmdShow::execute (const std::string& command_line, std::string& output)
defaultPriority != "M" && defaultPriority != "M" &&
defaultPriority != "L" && defaultPriority != "L" &&
defaultPriority != "") defaultPriority != "")
out << "Configuration error: default.priority contains an unrecognized value '" out << format (STRING_CMD_SHOW_CONFIG_ERROR, "default.priority", defaultPriority)
<< defaultPriority << "\n";
<< "'.\n";
// Verify installation. This is mentioned in the documentation as the way // Verify installation. This is mentioned in the documentation as the way
// to ensure everything is properly installed. // to ensure everything is properly installed.
@@ -304,12 +298,10 @@ int CmdShow::execute (const std::string& command_line, std::string& output)
Directory location (context.config.get ("data.location")); Directory location (context.config.get ("data.location"));
if (location.data == "") if (location.data == "")
out << "Configuration error: data.location not specified in .taskrc " out << STRING_CMD_SHOW_NO_LOCATION << "\n";
"file.\n";
if (! location.exists ()) if (! location.exists ())
out << "Configuration error: data.location contains a directory name" out << STRING_CMD_SHOW_LOC_EXIST << "\n";
" that doesn't exist, or is unreadable.\n";
} }
output = out.str (); output = out.str ();

View File

@@ -39,6 +39,11 @@
// - attribute names // - attribute names
// - modifier names // - modifier names
// //
// Rules:
// - Localized strings should contain leading or trailing white space,
// including \n
// -
//
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_EN_US #ifndef INCLUDED_EN_US
@@ -47,25 +52,29 @@
// To localize, clone and rename this file, then change all the defines below. // To localize, clone and rename this file, then change all the defines below.
// Errors // Errors
#define STRING_UNKNOWN_ERROR "Unknown error." #define STRING_UNKNOWN_ERROR "Unknown error."
#define STRING_NO_HOME "Could not read home directory from the passwd file." #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_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_TRIVIAL_INPUT "You must specify a command, or a task ID to modify."
#define STRING_ASSUME_INFO "No command - assuming 'info'" #define STRING_ASSUME_INFO "No command - assuming 'info'"
// 'show' command // 'show' command
#define STRING_CMD_SHOW "Shows the entire task configuration variables or the ones containing substring." #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_ARGS "You can only specify 'all' or a search string."
#define STRING_CMD_SHOW_NONE "No matching configuration variables." #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_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_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_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_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."
// DOM // DOM
#define STRING_DOM_UNKNOWN "<unknown>" #define STRING_DOM_UNKNOWN "<unknown>"
#define STRING_DOM_UNREC "DOM: Cannot get unrecognized name '{1}'." #define STRING_DOM_UNREC "DOM: Cannot get unrecognized name '{1}'."
#define STRING_DOM_CANNOT_SET "DOM: Cannot set '{1}'." #define STRING_DOM_CANNOT_SET "DOM: Cannot set '{1}'."
#endif #endif