diff --git a/src/Date.cpp b/src/Date.cpp index 478a77e14..9efb9ece0 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -25,6 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include @@ -35,6 +37,7 @@ #include #include #include +#include #include extern Context context; @@ -102,7 +105,7 @@ Date::Date (const std::string& input, const std::string& format /* = "m/d/Y" */) if (n.getDate (format, mT) && n.depleted ()) return; - throw std::string ("'") + input + "' is not a valid date in the '" + format + "' format."; + throw ::format (STRING_DATE_INVALID_FORMAT, input, format); } //////////////////////////////////////////////////////////////////////////////// @@ -391,8 +394,7 @@ int Date::weekOfYear (int weekStart) const else if (weekStart == 1) strftime(weekStr, sizeof(weekStr), "%V", t); else - throw std::string ("The 'weekstart' configuration variable may " - "only contain 'Sunday' or 'Monday'."); + throw std::string (STRING_DATE_BAD_WEEKSTART); int weekNumber = atoi (weekStr); diff --git a/src/commands/CmdHistory.cpp b/src/commands/CmdHistory.cpp index fd048d882..42e7967ad 100644 --- a/src/commands/CmdHistory.cpp +++ b/src/commands/CmdHistory.cpp @@ -25,11 +25,14 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include #include #include +#include #include extern Context context; @@ -39,7 +42,7 @@ CmdHistoryMonthly::CmdHistoryMonthly () { _keyword = "history.monthly"; _usage = "task history.monthly []"; - _description = "Shows a report of task history, by month."; + _description = STRING_CMD_HISTORY_USAGE_M; _read_only = true; _displays_id = false; } @@ -101,12 +104,12 @@ int CmdHistoryMonthly::execute (std::string& output) // Now build the view. ViewText view; view.width (context.getWidth ()); - view.add (Column::factory ("string", "Year")); - view.add (Column::factory ("string", "Month")); - view.add (Column::factory ("string.right", "Added")); - view.add (Column::factory ("string.right", "Completed")); - view.add (Column::factory ("string.right", "Deleted")); - view.add (Column::factory ("string.right", "Net")); + view.add (Column::factory ("string", STRING_CMD_HISTORY_YEAR)); + view.add (Column::factory ("string", STRING_CMD_HISTORY_MONTH)); + view.add (Column::factory ("string.right", STRING_CMD_HISTORY_ADDED)); + view.add (Column::factory ("string.right", STRING_CMD_HISTORY_COMP)); + view.add (Column::factory ("string.right", STRING_CMD_HISTORY_DEL)); + view.add (Column::factory ("string.right", STRING_CMD_HISTORY_NET)); int totalAdded = 0; int totalCompleted = 0; @@ -173,7 +176,7 @@ int CmdHistoryMonthly::execute (std::string& output) if (context.color ()) row_color = Color (Color::nocolor, Color::nocolor, false, true, false); - view.set (row, 1, "Average", row_color); + view.set (row, 1, STRING_CMD_HISTORY_AVERAGE, row_color); view.set (row, 2, totalAdded / (view.rows () - 2), row_color); view.set (row, 3, totalCompleted / (view.rows () - 2), row_color); view.set (row, 4, totalDeleted / (view.rows () - 2), row_color); @@ -187,7 +190,7 @@ int CmdHistoryMonthly::execute (std::string& output) << "\n"; else { - out << "No tasks.\n"; + out << STRING_CMD_HISTORY_NO_TASKS << "\n"; rc = 1; } @@ -200,7 +203,7 @@ CmdHistoryAnnual::CmdHistoryAnnual () { _keyword = "history.annual"; _usage = "task history.annual []"; - _description = "Shows a report of task history, by year."; + _description = STRING_CMD_HISTORY_USAGE_A; _read_only = true; _displays_id = false; } @@ -261,11 +264,11 @@ int CmdHistoryAnnual::execute (std::string& output) // Now build the view. ViewText view; view.width (context.getWidth ()); - view.add (Column::factory ("string", "Year")); - view.add (Column::factory ("string.right", "Added")); - view.add (Column::factory ("string.right", "Completed")); - view.add (Column::factory ("string.right", "Deleted")); - view.add (Column::factory ("string.right", "Net")); + view.add (Column::factory ("string", STRING_CMD_HISTORY_YEAR)); + view.add (Column::factory ("string.right", STRING_CMD_HISTORY_ADDED)); + view.add (Column::factory ("string.right", STRING_CMD_HISTORY_COMP)); + view.add (Column::factory ("string.right", STRING_CMD_HISTORY_DEL)); + view.add (Column::factory ("string.right", STRING_CMD_HISTORY_NET)); int totalAdded = 0; int totalCompleted = 0; @@ -330,7 +333,7 @@ int CmdHistoryAnnual::execute (std::string& output) if (context.color ()) row_color = Color (Color::nocolor, Color::nocolor, false, true, false); - view.set (row, 0, "Average", row_color); + view.set (row, 0, STRING_CMD_HISTORY_AVERAGE, row_color); view.set (row, 1, totalAdded / (view.rows () - 2), row_color); view.set (row, 2, totalCompleted / (view.rows () - 2), row_color); view.set (row, 3, totalDeleted / (view.rows () - 2), row_color); @@ -344,7 +347,7 @@ int CmdHistoryAnnual::execute (std::string& output) << "\n"; else { - out << "No tasks.\n"; + out << STRING_CMD_HISTORY_NO_TASKS << "\n"; rc = 1; } @@ -357,7 +360,7 @@ CmdGHistoryMonthly::CmdGHistoryMonthly () { _keyword = "ghistory.monthly"; _usage = "task ghistory.monthly []"; - _description = "Shows a graphical report of task history, by month."; + _description = STRING_CMD_GHISTORY_USAGE_M; _read_only = true; _displays_id = false; } @@ -420,9 +423,9 @@ int CmdGHistoryMonthly::execute (std::string& output) // Now build the view. ViewText view; view.width (context.getWidth ()); - view.add (Column::factory ("string", "Year")); - view.add (Column::factory ("string", "Month")); - view.add (Column::factory ("string", "Number Added/Completed/Deleted")); + view.add (Column::factory ("string", STRING_CMD_GHISTORY_YEAR)); + view.add (Column::factory ("string", STRING_CMD_GHISTORY_MONTH)); + view.add (Column::factory ("string", STRING_CMD_GHISTORY_NUMBER)); Color color_add (context.config.get ("color.history.add")); Color color_done (context.config.get ("color.history.done")); @@ -531,20 +534,19 @@ int CmdGHistoryMonthly::execute (std::string& output) << "\n"; if (context.color ()) - out << "Legend: " - << color_add.colorize ("added") - << ", " - << color_done.colorize ("completed") - << ", " - << color_delete.colorize ("deleted") + out << format (STRING_CMD_HISTORY_LEGEND, + color_add.colorize (STRING_CMD_HISTORY_ADDED), + color_add.colorize (STRING_CMD_HISTORY_COMP), + color_add.colorize (STRING_CMD_HISTORY_DEL)) << optionalBlankLine () << "\n"; else - out << "Legend: + added, X completed, - deleted\n"; + out << STRING_CMD_HISTORY_LEGEND_A + << "\n"; } else { - out << "No tasks.\n"; + out << STRING_CMD_HISTORY_NO_TASKS << "\n"; rc = 1; } @@ -557,7 +559,7 @@ CmdGHistoryAnnual::CmdGHistoryAnnual () { _keyword = "ghistory.annual"; _usage = "task ghistory.annual []"; - _description = "Shows a graphical report of task history, by year."; + _description = STRING_CMD_GHISTORY_USAGE_A; _read_only = true; _displays_id = false; } @@ -620,8 +622,8 @@ int CmdGHistoryAnnual::execute (std::string& output) // Now build the view. ViewText view; view.width (context.getWidth ()); - view.add (Column::factory ("string", "Year")); - view.add (Column::factory ("string.left_fixed", "Number Added/Completed/Deleted")); + view.add (Column::factory ("string", STRING_CMD_GHISTORY_YEAR)); + view.add (Column::factory ("string", STRING_CMD_GHISTORY_NUMBER)); Color color_add (context.config.get ("color.history.add")); Color color_done (context.config.get ("color.history.done")); @@ -728,20 +730,19 @@ int CmdGHistoryAnnual::execute (std::string& output) << "\n"; if (context.color ()) - out << "Legend: " - << color_add.colorize ("added") - << ", " - << color_done.colorize ("completed") - << ", " - << color_delete.colorize ("deleted") + out << format (STRING_CMD_HISTORY_LEGEND, + color_add.colorize (STRING_CMD_HISTORY_ADDED), + color_add.colorize (STRING_CMD_HISTORY_COMP), + color_add.colorize (STRING_CMD_HISTORY_DEL)) << optionalBlankLine () << "\n"; else - out << "Legend: + added, X completed, - deleted\n"; + out << STRING_CMD_HISTORY_LEGEND_A + << "\n"; } else { - out << "No tasks.\n"; + out << STRING_CMD_HISTORY_NO_TASKS << "\n"; rc = 1; } diff --git a/src/en-US.h b/src/en-US.h index 51cb3f44c..ec37e777a 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -214,6 +214,23 @@ #define STRING_CMD_TAGS_SINGLE "1 tag" #define STRING_CMD_TAGS_PLURAL "{1} tags" #define STRING_CMD_TAGS_NO_TAGS "No tags." +#define STRING_CMD_HISTORY_USAGE_M "Shows a report of task history, by month." +#define STRING_CMD_HISTORY_YEAR "Year" +#define STRING_CMD_HISTORY_MONTH "Month" +#define STRING_CMD_HISTORY_ADDED "Added" +#define STRING_CMD_HISTORY_COMP "Completed" +#define STRING_CMD_HISTORY_DEL "Deleted" +#define STRING_CMD_HISTORY_NET "Net" +#define STRING_CMD_HISTORY_USAGE_A "Shows a report of task history, by year." +#define STRING_CMD_HISTORY_NO_TASKS "No tasks." +#define STRING_CMD_HISTORY_AVERAGE "Average" +#define STRING_CMD_HISTORY_LEGEND "Legend: {1}, {2}, {3}" +#define STRING_CMD_HISTORY_LEGEND_A "Legend: + added, X completed, - deleted" +#define STRING_CMD_GHISTORY_USAGE_M "Shows a graphical report of task history, by month." +#define STRING_CMD_GHISTORY_USAGE_A "Shows a graphical report of task history, by year." +#define STRING_CMD_GHISTORY_YEAR "Year" +#define STRING_CMD_GHISTORY_MONTH "Month" +#define STRING_CMD_GHISTORY_NUMBER "Number Added/Completed/Deleted" // Config #define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake." @@ -228,6 +245,10 @@ #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." +// Date +#define STRING_DATE_INVALID_FORMAT "'{1}' is not a valid date in the '{2}' format." +#define STRING_DATE_BAD_WEEKSTART "The 'weekstart' configuration variable may only contain 'Sunday' or 'Monday'." + // dependency #define STRING_DEPEND_BLOCKED "Task {1} is blocked by:" #define STRING_DEPEND_BLOCKING "and is blocking:" @@ -284,6 +305,9 @@ #define STRING_RECORD_JUNK_AT_EOL "Unrecognized characters at end of line." #define STRING_RECORD_NOT_FF4 "Record not recognized as format 4." +// recur +#define STRING_RECUR_PAST_UNTIL "Task ({1}) has past its 'until' date, and has been deleted." + // '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." diff --git a/src/recur.cpp b/src/recur.cpp index 1e185a25b..1c5cbfc92 100644 --- a/src/recur.cpp +++ b/src/recur.cpp @@ -25,6 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include @@ -42,6 +44,7 @@ #include #include #include +#include #include // Global context for use by all. @@ -68,9 +71,8 @@ void handleRecurrence () std::vector due; if (!generateDueDates (*t, due)) { - std::cout << "Task (" - << trim (t->get ("description")) - << ") has past its 'until' date, and has been deleted.\n"; + std::cout << format (STRING_RECUR_PAST_UNTIL, trim (t->get ("description"))) + << "\n"; // Determine the end date. char endTime[16];