- Localized 'timesheet' command.
This commit is contained in:
Paul Beckingham 2011-10-01 12:03:34 -04:00
parent 14343e8e4d
commit a59a2f7234
2 changed files with 19 additions and 13 deletions

View file

@ -25,12 +25,16 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <sstream> #include <sstream>
#include <stdlib.h> #include <stdlib.h>
#include <Context.h> #include <Context.h>
#include <ViewText.h> #include <ViewText.h>
#include <Date.h> #include <Date.h>
#include <main.h> #include <main.h>
#include <i18n.h>
#include <text.h>
#include <CmdTimesheet.h> #include <CmdTimesheet.h>
extern Context context; extern Context context;
@ -40,7 +44,7 @@ CmdTimesheet::CmdTimesheet ()
{ {
_keyword = "timesheet"; _keyword = "timesheet";
_usage = "task timesheet [weeks]"; _usage = "task timesheet [weeks]";
_description = "Shows a weekly report of tasks completed and started."; _description = STRING_CMD_TIMESHEET_USAGE;
_read_only = true; _read_only = true;
_displays_id = false; _displays_id = false;
} }
@ -58,8 +62,7 @@ int CmdTimesheet::execute (std::string& output)
// What day of the week does the user consider the first? // What day of the week does the user consider the first?
int weekStart = Date::dayOfWeek (context.config.get ("weekstart")); int weekStart = Date::dayOfWeek (context.config.get ("weekstart"));
if (weekStart != 0 && weekStart != 1) if (weekStart != 0 && weekStart != 1)
throw std::string ("The 'weekstart' configuration variable may " throw std::string (STRING_DATE_BAD_WEEKSTART);
"only contain 'Sunday' or 'Monday'.");
// Determine the date of the first day of the most recent report. // Determine the date of the first day of the most recent report.
Date today; Date today;
@ -95,9 +98,9 @@ int CmdTimesheet::execute (std::string& output)
ViewText completed; ViewText completed;
completed.width (context.getWidth ()); completed.width (context.getWidth ());
completed.add (Column::factory ("string", " ")); completed.add (Column::factory ("string", " "));
completed.add (Column::factory ("string", "Project")); completed.add (Column::factory ("string", STRING_COLUMN_LABEL_PROJECT));
completed.add (Column::factory ("string.right", "Due")); completed.add (Column::factory ("string.right", STRING_COLUMN_LABEL_DUE));
completed.add (Column::factory ("string", "Description")); completed.add (Column::factory ("string", STRING_COLUMN_LABEL_DESC));
std::vector <Task>::iterator task; std::vector <Task>::iterator task;
for (task = all.begin (); task != all.end (); ++task) for (task = all.begin (); task != all.end (); ++task)
@ -123,7 +126,7 @@ int CmdTimesheet::execute (std::string& output)
} }
} }
out << " Completed (" << completed.rows () << " tasks)\n"; out << " " << format (STRING_CMD_TIMESHEET_DONE, completed.rows ()) << "\n";
if (completed.rows ()) if (completed.rows ())
out << completed.render () out << completed.render ()
@ -133,9 +136,9 @@ int CmdTimesheet::execute (std::string& output)
ViewText started; ViewText started;
started.width (context.getWidth ()); started.width (context.getWidth ());
started.add (Column::factory ("string", " ")); started.add (Column::factory ("string", " "));
started.add (Column::factory ("string", "Project")); started.add (Column::factory ("string", STRING_COLUMN_LABEL_PROJECT));
started.add (Column::factory ("string.right", "Due")); started.add (Column::factory ("string.right", STRING_COLUMN_LABEL_DUE));
started.add (Column::factory ("string", "Description")); started.add (Column::factory ("string", STRING_COLUMN_LABEL_DESC));
for (task = all.begin (); task != all.end (); ++task) for (task = all.begin (); task != all.end (); ++task)
{ {
@ -162,7 +165,7 @@ int CmdTimesheet::execute (std::string& output)
} }
} }
out << " Started (" << started.rows () << " tasks)\n"; out << " " << format (STRING_CMD_TIMESHEET_STARTED, started.rows ()) << "\n";
if (started.rows ()) if (started.rows ())
out << started.render () out << started.render ()

View file

@ -400,6 +400,9 @@
#define STRING_CMD_CUSTOM_COUNT "1 task" #define STRING_CMD_CUSTOM_COUNT "1 task"
#define STRING_CMD_CUSTOM_COUNTN "{1} tasks" #define STRING_CMD_CUSTOM_COUNTN "{1} tasks"
#define STRING_CMD_CUSTOM_TRUNCATED "truncated to {1} lines" #define STRING_CMD_CUSTOM_TRUNCATED "truncated to {1} lines"
#define STRING_CMD_TIMESHEET_USAGE "Shows a weekly report of tasks completed and started."
#define STRING_CMD_TIMESHEET_STARTED "Started ({1} tasks)"
#define STRING_CMD_TIMESHEET_DONE "Completed ({1} tasks)"
// Config // Config
#define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake." #define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake."