From e5139780ea532d57bce09968be806be0f8e1a1cd Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 10 Jul 2011 11:08:40 -0400 Subject: [PATCH] I18N - Localized more commands. --- src/commands/CmdAdd.cpp | 2 +- src/commands/CmdDelete.cpp | 64 ++++++++++++++++------------------- src/commands/CmdDone.cpp | 9 ++--- src/commands/CmdDuplicate.cpp | 18 +++++----- src/commands/CmdImport.cpp | 6 +--- src/commands/CmdStart.cpp | 25 +++++++------- src/commands/CmdStop.cpp | 25 +++++++------- src/en-US.h | 16 +++++++++ 8 files changed, 85 insertions(+), 80 deletions(-) diff --git a/src/commands/CmdAdd.cpp b/src/commands/CmdAdd.cpp index 8875ed74b..4c9e0fe7b 100644 --- a/src/commands/CmdAdd.cpp +++ b/src/commands/CmdAdd.cpp @@ -40,7 +40,7 @@ extern Context context; CmdAdd::CmdAdd () { _keyword = "add"; - _usage = "task add [tags] [attrs] desc..."; + _usage = "task add "; _description = STRING_CMD_ADD_USAGE; _read_only = false; _displays_id = false; diff --git a/src/commands/CmdDelete.cpp b/src/commands/CmdDelete.cpp index 0948ac4e3..6161c1f63 100644 --- a/src/commands/CmdDelete.cpp +++ b/src/commands/CmdDelete.cpp @@ -25,6 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include @@ -40,8 +42,8 @@ extern Context context; CmdDelete::CmdDelete () { _keyword = "delete"; - _usage = "task delete ID"; - _description = "Deletes the specified task."; + _usage = "task delete []"; + _description = STRING_CMD_DELETE_USAGE; _read_only = false; _displays_id = false; } @@ -83,21 +85,18 @@ int CmdDelete::execute (std::string& output) modify_task_annotate (*task, modifications); apply_defaults (*task); - std::stringstream question; - question << "Permanently delete task " - << task->id - << " '" - << task->get ("description") - << "'?"; + std::string question = format (STRING_CMD_DELETE_QUESTION, + task->id, + task->get ("description")); - if (!context.config.getBoolean ("confirmation") || confirm (question.str ())) + if (!context.config.getBoolean ("confirmation") || confirm (question)) { // Check for the more complex case of a recurring task. If this is a // recurring task, get confirmation to delete them all. std::string parent = task->get ("parent"); if (parent != "") { - if (confirm ("This is a recurring task. Do you want to delete all pending recurrences of this same task?")) + if (confirm (STRING_CMD_DELETE_CONF_RECUR)) { // Scan all pending tasks for siblings of this task, and the parent // itself, and delete them. @@ -112,7 +111,7 @@ int CmdDelete::execute (std::string& output) // Don't want a 'delete' to clobber the end date that may have // been written by a 'done' command. if (! sibling->has ("end")) - sibling->set ("end", endTime); + sibling->setEnd (); // Apply the command line modifications to the sibling. modify_task_annotate (*sibling, modifications); @@ -122,12 +121,12 @@ int CmdDelete::execute (std::string& output) context.tdb.update (*sibling); ++count; + // TODO Feedback. if (context.config.getBoolean ("echo.command")) - out << "Deleting recurring task " - << sibling->id - << " '" - << sibling->get ("description") - << "'.\n"; + out << format (STRING_CMD_DELETE_RECURRING, + sibling->id, + sibling->get ("description")) + << "\n"; } } } @@ -140,17 +139,16 @@ int CmdDelete::execute (std::string& output) // Don't want a 'delete' to clobber the end date that may have // been written by a 'done' command. if (! task->has ("end")) - task->set ("end", endTime); + task->setEnd (); task->validate (); context.tdb.update (*task); ++count; - out << "Deleting recurring task " - << task->id - << " '" - << task->get ("description") - << "'.\n"; + out << format (STRING_CMD_DELETE_RECURRING, + task->id, + task->get ("description")) + << "\n"; dependencyChainOnComplete (*task); context.footnote (onProjectChange (*task)); @@ -163,18 +161,17 @@ int CmdDelete::execute (std::string& output) // Don't want a 'delete' to clobber the end date that may have // been written by a 'done' command. if (! task->has ("end")) - task->set ("end", endTime); + task->setEnd (); task->validate (); context.tdb.update (*task); ++count; if (context.config.getBoolean ("echo.command")) - out << "Deleting task " - << task->id - << " '" - << task->get ("description") - << "'.\n"; + out << format (STRING_CMD_DELETE_DELETING, + task->id, + task->get ("description")) + << "\n"; dependencyChainOnComplete (*task); context.footnote (onProjectChange (*task)); @@ -182,17 +179,16 @@ int CmdDelete::execute (std::string& output) } else { - out << "Task not deleted.\n"; + out << STRING_CMD_DELETE_NOT << "\n"; rc = 1; } } else { - out << "Task " - << task->id - << " '" - << task->get ("description") - << "' is neither pending nor waiting.\n"; + out << format (STRING_CMD_DELETE_NOTPEND, + task->id, + task->get ("description")) + << "\n"; rc = 1; } } diff --git a/src/commands/CmdDone.cpp b/src/commands/CmdDone.cpp index b8ac425c7..5e5ed0805 100644 --- a/src/commands/CmdDone.cpp +++ b/src/commands/CmdDone.cpp @@ -41,7 +41,7 @@ extern Context context; CmdDone::CmdDone () { _keyword = "done"; - _usage = "task done ID [tags] [attrs] [desc...]"; + _usage = "task done []"; _description = STRING_CMD_DONE_USAGE; _read_only = false; _displays_id = false; @@ -87,12 +87,7 @@ int CmdDone::execute (std::string& output) modify_task_annotate (*task, modifications); apply_defaults (*task); - // Add an end date. - char entryTime[16]; - sprintf (entryTime, "%u", (unsigned int) time (NULL)); - task->set ("end", entryTime); - - // Change status. + task->setEnd (); task->setStatus (Task::completed); // Stop the task, if started. diff --git a/src/commands/CmdDuplicate.cpp b/src/commands/CmdDuplicate.cpp index 46abb922a..cf3e7cc75 100644 --- a/src/commands/CmdDuplicate.cpp +++ b/src/commands/CmdDuplicate.cpp @@ -25,6 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include @@ -40,7 +42,7 @@ CmdDuplicate::CmdDuplicate () { _keyword = "duplicate"; _usage = "task duplicate []"; - _description = "Duplicates the specified tasks, and allows modifications."; + _description = STRING_CMD_DUPLICATE_USAGE; _read_only = false; _displays_id = false; } @@ -88,9 +90,8 @@ int CmdDuplicate::execute (std::string& output) dup.remove ("imak"); dup.remove ("imask"); - out << "Note: task " - << task->id - << " was a recurring task. The duplicate task is not.\n"; + out << format (STRING_CMD_DUPLICATE_NON_REC, task->id) + << "\n"; } modify_task_annotate (dup, modifications); @@ -103,11 +104,10 @@ int CmdDuplicate::execute (std::string& output) ++count; if (context.config.getBoolean ("echo.command")) - out << "Duplicated " - << task->id - << " '" - << task->get ("description") - << "'.\n"; + out << format (STRING_CMD_DUPLICATE_DONE, + task->id, + task->get ("description")) + << "\n"; // TODO This should be a call in to feedback.cpp. if (context.verbose ("new-id")) diff --git a/src/commands/CmdImport.cpp b/src/commands/CmdImport.cpp index 3ad3723ba..4b41157c0 100644 --- a/src/commands/CmdImport.cpp +++ b/src/commands/CmdImport.cpp @@ -173,11 +173,7 @@ CmdImport::fileType CmdImport::determineFileType (const std::vector #include #include #include +#include #include #include @@ -38,8 +41,8 @@ extern Context context; CmdStart::CmdStart () { _keyword = "start"; - _usage = "task start ID"; - _description = "Marks specified task as started."; + _usage = "task start []"; + _description = STRING_CMD_START_USAGE; _read_only = false; _displays_id = false; } @@ -102,11 +105,10 @@ int CmdStart::execute (std::string& output) ++count; if (context.config.getBoolean ("echo.command")) - out << "Started " - << task->id - << " '" - << task->get ("description") - << "'.\n"; + out << format (STRING_CMD_START_DONE, + task->id, + task->get ("description")) + << "\n"; dependencyChainOnStart (*task); } @@ -117,11 +119,10 @@ int CmdStart::execute (std::string& output) } else { - out << "Task " - << task->id - << " '" - << task->get ("description") - << "' already started.\n"; + out << format (STRING_CMD_START_ALREADY, + task->id, + task->get ("description")) + << "\n"; rc = 1; } } diff --git a/src/commands/CmdStop.cpp b/src/commands/CmdStop.cpp index f691c4f5f..5af30fd83 100644 --- a/src/commands/CmdStop.cpp +++ b/src/commands/CmdStop.cpp @@ -25,10 +25,13 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include #include +#include #include #include @@ -38,8 +41,8 @@ extern Context context; CmdStop::CmdStop () { _keyword = "stop"; - _usage = "task stop ID"; - _description = "Removes the 'start' time from a task."; + _usage = "task stop []"; + _description = STRING_CMD_STOP_USAGE; _read_only = false; _displays_id = false; } @@ -99,21 +102,19 @@ int CmdStop::execute (std::string& output) ++count; if (context.config.getBoolean ("echo.command")) - out << "Stopped " - << task->id - << " '" - << task->get ("description") - << "'.\n"; + out << format (STRING_CMD_STOP_DONE, + task->id, + task->get ("description")) + << "\n"; } } } else { - out << "Task " - << task->id - << " '" - << task->get ("description") - << "' not started.\n"; + out << format (STRING_CMD_STOP_NOT, + task->id, + task->get ("description")) + << "\n"; rc = 1; } } diff --git a/src/en-US.h b/src/en-US.h index 5680f2f4c..4916548eb 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -258,6 +258,22 @@ #define STRING_CMD_SUMMARY_AVG_AGE "Avg age" #define STRING_CMD_SUMMARY_COMPLETE "Complete" #define STRING_CMD_COUNT_USAGE "Shows only the number of matching tasks." +#define STRING_CMD_DELETE_USAGE "Deletes the specified task." +#define STRING_CMD_DELETE_QUESTION "Permanently delete task {1} '{2}'?" +#define STRING_CMD_DELETE_RECURRING "Deleting recurring task {1} '{2}'." +#define STRING_CMD_DELETE_DELETING "Deleting task {1} '{2}'." +#define STRING_CMD_DELETE_CONF_RECUR "This is a recurring task. Do you want to delete all pending recurrences of this same task?" +#define STRING_CMD_DELETE_NOT "Task not deleted." +#define STRING_CMD_DELETE_NOTPEND "Task {1} '{2}' is neither pending nor waiting." +#define STRING_CMD_DUPLICATE_USAGE "Duplicates the specified tasks, and allows modifications." +#define STRING_CMD_DUPLICATE_NON_REC "Note: task {1} was a recurring task. The duplicate task is not." +#define STRING_CMD_DUPLICATE_DONE "Duplicated {1} '{2}'." +#define STRING_CMD_START_USAGE "Marks specified task as started." +#define STRING_CMD_START_DONE "Started {1} '{2}'." +#define STRING_CMD_START_ALREADY "Task {1} '{2}' already started." +#define STRING_CMD_STOP_USAGE "Removes the 'start' time from a task." +#define STRING_CMD_STOP_NOT "Task {1} '{2}' not started." +#define STRING_CMD_STOP_DONE "Stopped {1} '{2}'." // Config #define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake."