- Localized all column objects, some commands.
This commit is contained in:
Paul Beckingham 2011-06-16 20:28:46 -04:00
parent c7bfba103e
commit 6a48d86f2c
22 changed files with 245 additions and 113 deletions

View file

@ -25,6 +25,8 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <sstream> #include <sstream>
#include <Context.h> #include <Context.h>
#include <Nibbler.h> #include <Nibbler.h>
@ -132,7 +134,7 @@ const std::string DOM::get (const std::string& name)
} }
else else
throw std::string ("DOM: Cannot get unrecognized name '") + name + "'."; throw format (STRING_DOM_UNREC, name);
} }
// <id>.<name> // <id>.<name>
@ -152,6 +154,11 @@ const std::string DOM::get (const std::string& name)
// TODO <uuid>.<name> // TODO <uuid>.<name>
else if (n.getUUID (uuid)) else if (n.getUUID (uuid))
{ {
std::string attr;
if (n.skip ('.') &&
n.getUntilEOS (attr))
{
}
} }
// TODO report. // TODO report.
@ -192,7 +199,7 @@ const std::string DOM::get (const std::string& name)
#endif #endif
else else
throw std::string ("DOM: Cannot get unrecognized name '") + name + "'."; throw format (STRING_DOM_UNREC, name);
} }
return ""; return "";
@ -212,7 +219,7 @@ void DOM::set (const std::string& name, const std::string& value)
// Unrecognized --> error. // Unrecognized --> error.
else else
throw std::string ("DOM: Cannot set '") + name + "'."; throw format (STRING_DOM_CANNOT_SET, name);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -25,19 +25,22 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <stdlib.h> #include <stdlib.h>
#include <Context.h> #include <Context.h>
#include <ColDue.h> #include <ColDue.h>
#include <Date.h> #include <Date.h>
#include <Duration.h> #include <Duration.h>
#include <text.h> #include <text.h>
#include <i18n.h>
extern Context context; extern Context context;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ColumnDue::ColumnDue () ColumnDue::ColumnDue ()
{ {
_label = "Due"; _label = STRING_COLUMN_LABEL_DUE;
_attribute = "due"; _attribute = "due";
} }
@ -53,8 +56,8 @@ void ColumnDue::setStyle (const std::string& value)
{ {
_style = value; _style = value;
if (_style == "countdown" && _label == "Due") if (_style == "countdown" && _label == STRING_COLUMN_LABEL_DUE)
_label = "Countdown"; _label = STRING_COLUMN_LABEL_COUNT;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -25,12 +25,15 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <ColEnd.h> #include <ColEnd.h>
#include <i18n.h>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ColumnEnd::ColumnEnd () ColumnEnd::ColumnEnd ()
{ {
_label = "Completed"; _label = STRING_COLUMN_LABEL_COMPLETE;
_attribute = "end"; _attribute = "end";
} }

View file

@ -25,12 +25,15 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <ColEntry.h> #include <ColEntry.h>
#include <i18n.h>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ColumnEntry::ColumnEntry () ColumnEntry::ColumnEntry ()
{ {
_label = "Added"; _label = STRING_COLUMN_LABEL_ADDED;
_attribute = "entry"; _attribute = "entry";
} }
@ -46,7 +49,9 @@ void ColumnEntry::setStyle (const std::string& value)
{ {
_style = value; _style = value;
if (_style == "age" && _label == "Added") _label = "Age"; if (_style == "age" &&
_label == STRING_COLUMN_LABEL_ADDED)
_label = STRING_COLUMN_LABEL_AGE;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -25,10 +25,13 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <math.h> #include <math.h>
#include <Context.h> #include <Context.h>
#include <ColID.h> #include <ColID.h>
#include <text.h> #include <text.h>
#include <i18n.h>
extern Context context; extern Context context;
@ -37,7 +40,7 @@ ColumnID::ColumnID ()
{ {
_type = "number"; _type = "number";
_style = "default"; _style = "default";
_label = "ID"; _label = STRING_COLUMN_LABEL_ID;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -60,7 +63,7 @@ void ColumnID::measure (Task& task, int& minimum, int& maximum)
minimum = maximum = length; minimum = maximum = length;
if (_style != "default") if (_style != "default")
throw std::string ("Unrecognized column format 'id.") + _style + "'"; throw format (STRING_COLUMN_BAD_FORMAT, "id", _style);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -25,9 +25,12 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <Context.h> #include <Context.h>
#include <ColPriority.h> #include <ColPriority.h>
#include <text.h> #include <text.h>
#include <i18n.h>
extern Context context; extern Context context;
@ -36,7 +39,7 @@ ColumnPriority::ColumnPriority ()
{ {
_type = "string"; _type = "string";
_style = "default"; _style = "default";
_label = "Pri"; _label = STRING_COLUMN_LABEL_PRI;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -51,8 +54,8 @@ void ColumnPriority::setStyle (const std::string& value)
{ {
_style = value; _style = value;
if (_style == "long" && _label == "Pri") if (_style == "long" && _label == STRING_COLUMN_LABEL_PRI)
_label = "Priority"; _label = STRING_COLUMN_LABEL_PRIORITY;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -69,7 +72,7 @@ void ColumnPriority::measure (Task& task, int& minimum, int& maximum)
else if (priority == "L") minimum = maximum = 3; else if (priority == "L") minimum = maximum = 3;
} }
else if (_style != "default") else if (_style != "default")
throw std::string ("Unrecognized column format 'priority.") + _style + "'"; throw format (STRING_COLUMN_BAD_FORMAT, "priority", _style);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -25,9 +25,12 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <Context.h> #include <Context.h>
#include <ColProject.h> #include <ColProject.h>
#include <text.h> #include <text.h>
#include <i18n.h>
extern Context context; extern Context context;
@ -36,7 +39,7 @@ ColumnProject::ColumnProject ()
{ {
_type = "string"; _type = "string";
_style = "default"; _style = "default";
_label = "Project"; _label = STRING_COLUMN_LABEL_PROJECT;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -57,7 +60,7 @@ void ColumnProject::measure (Task& task, int& minimum, int& maximum)
project = project.substr (0, period); project = project.substr (0, period);
} }
else if (_style != "default") else if (_style != "default")
throw std::string ("Unrecognized column format 'project.") + _style + "'"; throw format (STRING_COLUMN_BAD_FORMAT, "project.", _style);
minimum = longestWord (project); minimum = longestWord (project);
maximum = project.length (); maximum = project.length ();

View file

@ -25,9 +25,12 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <Context.h> #include <Context.h>
#include <ColRecur.h> #include <ColRecur.h>
#include <text.h> #include <text.h>
#include <i18n.h>
extern Context context; extern Context context;
@ -36,7 +39,7 @@ ColumnRecur::ColumnRecur ()
{ {
_type = "string"; _type = "string";
_style = "default"; _style = "default";
_label = "Recur"; _label = STRING_COLUMN_LABEL_RECUR;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -51,7 +54,7 @@ void ColumnRecur::setStyle (const std::string& value)
{ {
_style = value; _style = value;
if (_style == "indicator" && _label == "Recur") if (_style == "indicator" && _label == STRING_COLUMN_LABEL_RECUR)
_label = _label.substr (0, context.config.get ("recurrence.indicator").length ()); _label = _label.substr (0, context.config.get ("recurrence.indicator").length ());
} }
@ -69,7 +72,7 @@ void ColumnRecur::measure (Task& task, int& minimum, int& maximum)
minimum = maximum = context.config.get ("recurrence.indicator").length (); minimum = maximum = context.config.get ("recurrence.indicator").length ();
} }
else else
throw std::string ("Unrecognized column format 'recur.") + _style + "'"; throw format (STRING_COLUMN_BAD_FORMAT, "recur.", _style);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -25,16 +25,19 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <Context.h> #include <Context.h>
#include <ColStart.h> #include <ColStart.h>
#include <text.h> #include <text.h>
#include <i18n.h>
extern Context context; extern Context context;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ColumnStart::ColumnStart () ColumnStart::ColumnStart ()
{ {
_label = "Started"; _label = STRING_COLUMN_LABEL_STARTED;
_attribute = "start"; _attribute = "start";
} }
@ -50,8 +53,8 @@ void ColumnStart::setStyle (const std::string& value)
{ {
_style = value; _style = value;
if (_style == "active" && _label == "Started") if (_style == "active" && _label == STRING_COLUMN_LABEL_STARTED)
_label = "A"; _label = STRING_COLUMN_LABEL_ACTIVE;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -25,9 +25,12 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <Context.h> #include <Context.h>
#include <ColStatus.h> #include <ColStatus.h>
#include <text.h> #include <text.h>
#include <i18n.h>
extern Context context; extern Context context;
@ -36,7 +39,7 @@ ColumnStatus::ColumnStatus ()
{ {
_type = "string"; _type = "string";
_style = "default"; _style = "default";
_label = "Status"; _label = STRING_COLUMN_LABEL_STATUS;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -51,8 +54,8 @@ void ColumnStatus::setStyle (const std::string& value)
{ {
_style = value; _style = value;
if (_style == "short" && _label == "Status") if (_style == "short" && _label == STRING_COLUMN_LABEL_STATUS)
_label = "St"; _label = STRING_COLUMN_LABEL_STAT;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -78,7 +81,7 @@ void ColumnStatus::measure (Task& task, int& minimum, int& maximum)
else if (_style == "short") else if (_style == "short")
minimum = maximum = 1; minimum = maximum = 1;
else else
throw std::string ("Unrecognized column format 'status.") + _style + "'"; throw format (STRING_COLUMN_BAD_FORMAT, "status.", _style);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -93,20 +96,20 @@ void ColumnStatus::render (
if (_style == "default") if (_style == "default")
{ {
if (status == Task::pending) value = "Pending"; if (status == Task::pending) value = STRING_COLUMN_LABEL_STAT_PE;
else if (status == Task::completed) value = "Completed"; else if (status == Task::completed) value = STRING_COLUMN_LABEL_STAT_CO;
else if (status == Task::deleted) value = "Deleted"; else if (status == Task::deleted) value = STRING_COLUMN_LABEL_STAT_DE;
else if (status == Task::waiting) value = "Waiting"; else if (status == Task::waiting) value = STRING_COLUMN_LABEL_STAT_WA;
else if (status == Task::recurring) value = "Recurring"; else if (status == Task::recurring) value = STRING_COLUMN_LABEL_STAT_RE;
} }
else if (_style == "short") else if (_style == "short")
{ {
if (status == Task::pending) value = "P"; if (status == Task::pending) value = STRING_COLUMN_LABEL_STAT_P;
else if (status == Task::completed) value = "C"; else if (status == Task::completed) value = STRING_COLUMN_LABEL_STAT_C;
else if (status == Task::deleted) value = "D"; else if (status == Task::deleted) value = STRING_COLUMN_LABEL_STAT_D;
else if (status == Task::waiting) value = "W"; else if (status == Task::waiting) value = STRING_COLUMN_LABEL_STAT_W;
else if (status == Task::recurring) value = "R"; else if (status == Task::recurring) value = STRING_COLUMN_LABEL_STAT_R;
} }
lines.push_back (color.colorize (leftJustify (value, width))); lines.push_back (color.colorize (leftJustify (value, width)));

View file

@ -25,9 +25,12 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <Context.h> #include <Context.h>
#include <ColString.h> #include <ColString.h>
#include <text.h> #include <text.h>
#include <i18n.h>
extern Context context; extern Context context;
@ -69,7 +72,7 @@ void ColumnString::measure (const std::string& value, int& minimum, int& maximum
_style == "right_fixed") _style == "right_fixed")
minimum = maximum = strippedLength (value); minimum = maximum = strippedLength (value);
else else
throw std::string ("Unrecognized column format 'string.") + _style + "'"; throw format (STRING_COLUMN_BAD_FORMAT, "string.", _style);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -25,10 +25,13 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <algorithm> #include <algorithm>
#include <Context.h> #include <Context.h>
#include <ColTags.h> #include <ColTags.h>
#include <text.h> #include <text.h>
#include <i18n.h>
extern Context context; extern Context context;
@ -37,7 +40,7 @@ ColumnTags::ColumnTags ()
{ {
_type = "string"; _type = "string";
_style = "default"; _style = "default";
_label = "Tags"; _label = STRING_COLUMN_LABEL_TAGS;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -52,8 +55,13 @@ void ColumnTags::setStyle (const std::string& value)
{ {
_style = value; _style = value;
if (_style == "indicator" && _label == "Tags") _label = _label.substr (0, context.config.get ("tag.indicator").length ()); if (_style == "indicator" &&
else if (_style == "count" && _label == "Tags") _label = "Tag"; _label == STRING_COLUMN_LABEL_TAGS)
_label = _label.substr (0, context.config.get ("tag.indicator").length ());
else if (_style == "count" &&
_label == STRING_COLUMN_LABEL_TAGS)
_label = STRING_COLUMN_LABEL_TAG;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -80,8 +88,7 @@ void ColumnTags::measure (Task& task, int& minimum, int& maximum)
} }
} }
else else
throw std::string ("Unrecognized column format 'tags.") + _style + "'"; throw format (STRING_COLUMN_BAD_FORMAT, "tags.", _style);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -25,10 +25,13 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <math.h> #include <math.h>
#include <Context.h> #include <Context.h>
#include <ColUUID.h> #include <ColUUID.h>
#include <text.h> #include <text.h>
#include <i18n.h>
extern Context context; extern Context context;
@ -37,7 +40,7 @@ ColumnUUID::ColumnUUID ()
{ {
_type = "string"; _type = "string";
_style = "default"; _style = "default";
_label = "UUID"; _label = STRING_COLUMN_LABEL_UUID;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -52,7 +55,7 @@ void ColumnUUID::measure (Task&, int& minimum, int& maximum)
if (_style == "default") minimum = maximum = 36; if (_style == "default") minimum = maximum = 36;
else if (_style == "short") minimum = maximum = 8; else if (_style == "short") minimum = maximum = 8;
else else
throw std::string ("Unrecognized column format 'uuid.") + _style + "'"; throw format (STRING_COLUMN_BAD_FORMAT, "uuid.", _style);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -25,12 +25,15 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <ColUntil.h> #include <ColUntil.h>
#include <i18n.h>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ColumnUntil::ColumnUntil () ColumnUntil::ColumnUntil ()
{ {
_label = "Until"; _label = STRING_COLUMN_LABEL_UNTIL;
_attribute = "until"; _attribute = "until";
} }

View file

@ -25,9 +25,12 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <Context.h> #include <Context.h>
#include <ColUrgency.h> #include <ColUrgency.h>
#include <text.h> #include <text.h>
#include <i18n.h>
extern Context context; extern Context context;
@ -36,7 +39,7 @@ ColumnUrgency::ColumnUrgency ()
{ {
_type = "number"; _type = "number";
_style = "default"; _style = "default";
_label = "Urgency"; _label = STRING_COLUMN_LABEL_URGENCY;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -51,7 +54,7 @@ void ColumnUrgency::measure (Task& task, int& minimum, int& maximum)
minimum = maximum = format (task.urgency (), 4, 3).length (); minimum = maximum = format (task.urgency (), 4, 3).length ();
if (_style != "default") if (_style != "default")
throw std::string ("Unrecognized column format 'urgency.") + _style + "'"; throw format (STRING_COLUMN_BAD_FORMAT, "urgency.", _style);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -25,12 +25,15 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <ColWait.h> #include <ColWait.h>
#include <i18n.h>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ColumnWait::ColumnWait () ColumnWait::ColumnWait ()
{ {
_label = "Wait"; _label = STRING_COLUMN_LABEL_WAIT;
_attribute = "wait"; _attribute = "wait";
} }

View file

@ -25,6 +25,8 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <Context.h> #include <Context.h>
#include <Column.h> #include <Column.h>
#include <ColDepends.h> #include <ColDepends.h>
@ -45,6 +47,7 @@
#include <ColUUID.h> #include <ColUUID.h>
#include <ColWait.h> #include <ColWait.h>
#include <text.h> #include <text.h>
#include <i18n.h>
extern Context context; extern Context context;
@ -91,7 +94,7 @@ Column* Column::factory (const std::string& name, const std::string& report)
// Special non-task column // Special non-task column
else if (column_name == "string") column = new ColumnString (); else if (column_name == "string") column = new ColumnString ();
else else
throw std::string ("Unrecognized column name '") + column_name + "'."; throw format (STRING_COLUMN_BAD_NAME, column_name);
column->setReport (report); column->setReport (report);
column->setStyle (column_style); column->setStyle (column_style);
@ -174,24 +177,28 @@ void Column::renderHeader (
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// No L10N.
void Column::measure (const std::string&, int&, int&) void Column::measure (const std::string&, int&, int&)
{ {
throw std::string ("Virtual method Column::measure not overriden."); throw std::string ("Virtual method Column::measure not overriden.");
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// No L10N.
void Column::measure (Task&, int&, int&) void Column::measure (Task&, int&, int&)
{ {
throw std::string ("Virtual method Column::measure not overriden."); throw std::string ("Virtual method Column::measure not overriden.");
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// No L10N.
void Column::render (std::vector <std::string>&, const std::string&, int, Color&) void Column::render (std::vector <std::string>&, const std::string&, int, Color&)
{ {
throw std::string ("Virtual method Column::render not overriden."); throw std::string ("Virtual method Column::render not overriden.");
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// No L10N.
void Column::render (std::vector <std::string>&, Task&, int, Color&) void Column::render (std::vector <std::string>&, Task&, int, Color&)
{ {
throw std::string ("Virtual method Column::render not overriden."); throw std::string ("Virtual method Column::render not overriden.");

View file

@ -104,7 +104,7 @@ int CmdCustom::execute (std::string& output)
std::cout << "# tasks=" << tasks.size () << "\n" std::cout << "# tasks=" << tasks.size () << "\n"
<< "# filtered=" << filtered.size () << "\n"; << "# filtered=" << filtered.size () << "\n";
return 0; //return 0;
//////////////////////////////////// ////////////////////////////////////

View file

@ -25,9 +25,12 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <CmdLogo.h> #include <CmdLogo.h>
#include <Context.h> #include <Context.h>
#include <text.h> #include <text.h>
#include <i18n.h>
extern Context context; extern Context context;
@ -36,7 +39,7 @@ CmdLogo::CmdLogo ()
{ {
_keyword = "logo"; _keyword = "logo";
_usage = "task logo"; _usage = "task logo";
_description = "Displays the Taskwarrior logo"; _description = STRING_CMD_LOGO_USAGE;
_read_only = true; _read_only = true;
_displays_id = false; _displays_id = false;
} }
@ -83,7 +86,7 @@ int CmdLogo::execute (std::string& output)
}; };
if (!context.color ()) if (!context.color ())
throw std::string ("The logo command requires that color support is enabled."); throw std::string (STRING_CMD_LOGO_COLOR_REQ);
std::string indent (context.config.getInteger ("indent.report"), ' '); std::string indent (context.config.getInteger ("indent.report"), ' ');
output += optionalBlankLine (); output += optionalBlankLine ();

View file

@ -25,6 +25,8 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <sstream> #include <sstream>
#include <stdlib.h> #include <stdlib.h>
#include <Context.h> #include <Context.h>
@ -32,6 +34,8 @@
#include <cmake.h> #include <cmake.h>
#include <commit.h> #include <commit.h>
#include <CmdVersion.h> #include <CmdVersion.h>
#include <text.h>
#include <i18n.h>
extern Context context; extern Context context;
@ -40,7 +44,7 @@ CmdVersion::CmdVersion ()
{ {
_keyword = "version"; _keyword = "version";
_usage = "task version"; _usage = "task version";
_description = "Shows the taskwarrior version number."; _description = STRING_CMD_VERSION_USAGE;
_read_only = true; _read_only = true;
_displays_id = false; _displays_id = false;
} }
@ -55,26 +59,20 @@ int CmdVersion::execute (std::string& output)
ViewText disclaimer; ViewText disclaimer;
disclaimer.width (width); disclaimer.width (width);
disclaimer.add (Column::factory ("string", "")); disclaimer.add (Column::factory ("string", ""));
disclaimer.set (disclaimer.addRow (), 0, disclaimer.set (disclaimer.addRow (), 0, STRING_CMD_VERSION_GPL);
"Taskwarrior may be copied only under the terms of the GNU General Public "
"License, which may be found in the taskwarrior source kit.");
// Create a table for the URL. // Create a table for the URL.
ViewText link; ViewText link;
link.width (width); link.width (width);
link.add (Column::factory ("string", "")); link.add (Column::factory ("string", ""));
link.set (link.addRow (), 0, link.set (link.addRow (), 0, STRING_CMD_VERSION_DOCS);
"Documentation for taskwarrior can be found using 'man task', 'man taskrc', "
"'man task-tutorial', 'man task-color', 'man task-sync', 'man task-faq' or at "
"http://taskwarrior.org");
Color bold ("bold"); Color bold ("bold");
out << "\n" out << "\n"
<< (context.color () ? bold.colorize (PACKAGE) : PACKAGE) << format (STRING_CMD_VERSION_BUILT,
<< " " (context.color () ? bold.colorize (PACKAGE) : PACKAGE),
<< (context.color () ? bold.colorize (VERSION) : VERSION) (context.color () ? bold.colorize (VERSION) : VERSION))
<< " built for "
#if defined (DARWIN) #if defined (DARWIN)
<< "darwin" << "darwin"
@ -91,11 +89,7 @@ int CmdVersion::execute (std::string& output)
#elif defined (LINUX) #elif defined (LINUX)
<< "linux" << "linux"
#else #else
<< "unknown" << STRING_CMD_VERSION_UNKNOWN
#endif
#ifdef HAVE_LIBREADLINE
<< "-readline"
#endif #endif
#ifdef HAVE_LIBLUA #ifdef HAVE_LIBLUA
@ -103,9 +97,11 @@ int CmdVersion::execute (std::string& output)
#endif #endif
<< "\n" << "\n"
<< "Copyright (C) 2006 - 2011 P. Beckingham, F. Hernandez.\n" << STRING_CMD_VERSION_COPY
<< "\n"
#ifdef HAVE_LIBLUA #ifdef HAVE_LIBLUA
<< "Portions of this software Copyright (C) 1994 2008 Lua.org, PUC-Rio.\n" << STRING_CMD_VERSION_COPY2
<< "\n"
#endif #endif
<< "\n" << "\n"
<< disclaimer.render () << disclaimer.render ()
@ -122,7 +118,7 @@ CmdCompletionVersion::CmdCompletionVersion ()
{ {
_keyword = "_version"; _keyword = "_version";
_usage = "task _version"; _usage = "task _version";
_description = "Shows only the taskwarrior version number."; _description = STRING_CMD_VERSION_USAGE2;
_read_only = true; _read_only = true;
_displays_id = false; _displays_id = false;
} }

View file

@ -27,8 +27,13 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// //
// This file contains all the strings that should be localized. If a string is
// *not* in this file, then either:
// (a) it should not be localized, or
// (b) you have found a bug - please report it
//
// Strings that should be localized: // Strings that should be localized:
// - text output that the user sees or types // - text output that the user sees
// //
// Strings that should NOT be localized: // Strings that should NOT be localized:
// - ./taskrc configuration variable names // - ./taskrc configuration variable names
@ -38,12 +43,13 @@
// - debug strings // - debug strings
// - attribute names // - attribute names
// - modifier names // - modifier names
// - logical operators (and, or, xor)
// //
// Rules: // Rules:
// - Localized strings should contain leading or trailing white space, // - Localized strings should contain leading or trailing white space,
// including \n, thus allowing the code to compose strings. // including \n, thus allowing the code to compose strings.
// - Retain the tense of the original string. // - Retain the tense of the original string.
// - Retain the same verbosiy of the original string. // - Retain the same degree of verbosity of the original string.
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -78,13 +84,14 @@
// cmake -D PACKAGE_LANGUAGE=LANGUAGE_DE_DE . // cmake -D PACKAGE_LANGUAGE=LANGUAGE_DE_DE .
// make // make
// //
// 5. Submit your translation to support@taskwarrior.org, for inclusion in // 5. Submit your translation to support@taskwarrior.org, where it will be
// next release. // shared with others.
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_STRINGS #ifndef INCLUDED_STRINGS
#define INCLUDED_STRINGS #define INCLUDED_STRINGS
#define L10N // Localization complete.
// API // API
#define STRING_API_EXITING "Exiting." #define STRING_API_EXITING "Exiting."
@ -95,11 +102,54 @@
#define STRING_API_WARNING "Warning: {1}" #define STRING_API_WARNING "Warning: {1}"
#define STRING_API_ERROR "Error: {1}" #define STRING_API_ERROR "Error: {1}"
// Columns // columns/Col*
#define STRING_COLUMN_BAD_NAME "Unrecognized column name '{1}'"
#define STRING_COLUMN_BAD_FORMAT "Unrecognized column format '{1}.{2}'" #define STRING_COLUMN_BAD_FORMAT "Unrecognized column format '{1}.{2}'"
#define STRING_COLUMN_LABEL_DEP "Depends" #define STRING_COLUMN_LABEL_DEP "Depends"
#define STRING_COLUMN_LABEL_DEP_S "Dep" #define STRING_COLUMN_LABEL_DEP_S "Dep"
#define STRING_COLUMN_LABEL_DESC "Description" #define STRING_COLUMN_LABEL_DESC "Description"
#define STRING_COLUMN_LABEL_DUE "Due"
#define STRING_COLUMN_LABEL_COUNT "Count"
#define STRING_COLUMN_LABEL_COMPLETE "Completed"
#define STRING_COLUMN_LABEL_ADDED "Added"
#define STRING_COLUMN_LABEL_AGE "Age"
#define STRING_COLUMN_LABEL_ID "ID"
#define STRING_COLUMN_LABEL_PRI "Pri"
#define STRING_COLUMN_LABEL_PRIORITY "Priority"
#define STRING_COLUMN_LABEL_PROJECT "Project"
#define STRING_COLUMN_LABEL_UNTIL "Until"
#define STRING_COLUMN_LABEL_WAIT "Wait"
#define STRING_COLUMN_LABEL_RECUR "Recur"
#define STRING_COLUMN_LABEL_STARTED "Started"
#define STRING_COLUMN_LABEL_ACTIVE "A"
#define STRING_COLUMN_LABEL_STATUS "Status"
#define STRING_COLUMN_LABEL_STAT "St"
#define STRING_COLUMN_LABEL_STAT_PE "Pending"
#define STRING_COLUMN_LABEL_STAT_CO "Completed"
#define STRING_COLUMN_LABEL_STAT_DE "Deleted"
#define STRING_COLUMN_LABEL_STAT_WA "Waiting"
#define STRING_COLUMN_LABEL_STAT_RE "Recurring"
#define STRING_COLUMN_LABEL_STAT_P "P"
#define STRING_COLUMN_LABEL_STAT_C "C"
#define STRING_COLUMN_LABEL_STAT_D "D"
#define STRING_COLUMN_LABEL_STAT_W "W"
#define STRING_COLUMN_LABEL_STAT_R "R"
#define STRING_COLUMN_LABEL_TAGS "Tags"
#define STRING_COLUMN_LABEL_TAG "Tag"
#define STRING_COLUMN_LABEL_UUID "UUID"
#define STRING_COLUMN_LABEL_URGENCY "Urgency"
// commands/Cmd*
#define STRING_CMD_VERSION_USAGE "Shows the taskwarrior version number."
#define STRING_CMD_VERSION_USAGE2 "Shows only the taskwarrior version number."
#define STRING_CMD_VERSION_GPL "Taskwarrior may be copied only under the terms of the GNU General Public License, which may be found in the taskwarrior source kit."
#define STRING_CMD_VERSION_DOCS "Documentation for taskwarrior can be found using 'man task', 'man taskrc', 'man task-tutorial', 'man task-color', 'man task-sync', 'man task-faq' or at http://taskwarrior.org"
#define STRING_CMD_VERSION_BUILT "{1} {2} built for "
#define STRING_CMD_VERSION_UNKNOWN "unknown"
#define STRING_CMD_VERSION_COPY "Copyright (C) 2006 - 2011 P. Beckingham, F. Hernandez."
#define STRING_CMD_VERSION_COPY2 "Portions of this software Copyright (C) 1994 2008 Lua.org, PUC-Rio."
#define STRING_CMD_LOGO_USAGE "Displays the Taskwarrior logo"
#define STRING_CMD_LOGO_COLOR_REQ "The logo command requires that color support is enabled."
// 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."
@ -160,6 +210,18 @@
#define STRING_UTF8_INVALID_CP_REP "Invalid codepoint representation." #define STRING_UTF8_INVALID_CP_REP "Invalid codepoint representation."
#define STRING_UTF8_INVALID_CP "Invalid Unicode codepoint." #define STRING_UTF8_INVALID_CP "Invalid Unicode codepoint."
// util
#define STRING_UTIL_CONFIRM_YN " (y/n) "
#define STRING_UTIL_CONFIRM_YES "yes"
#define STRING_UTIL_CONFIRM_YES_U "Yes"
#define STRING_UTIL_CONFIRM_NO "no"
#define STRING_UTIL_CONFIRM_ALL "all"
#define STRING_UTIL_CONFIRM_ALL_U "All"
#define STRING_UTIL_CONFIRM_QUIT "quit"
#define STRING_UTIL_GIBIBYTES "GiB"
#define STRING_UTIL_MEBIBYTES "MiB"
#define STRING_UTIL_KIBIBYTES "KiB"
#define STRING_UTIL_BYTES "B"
#endif #endif

View file

@ -24,6 +24,9 @@
// USA // USA
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
@ -57,23 +60,26 @@ extern Context context;
// std::getline, the newline can be detected, and the prompt re-written. // std::getline, the newline can be detected, and the prompt re-written.
bool confirm (const std::string& question) bool confirm (const std::string& question)
{ {
std::vector <std::string> options;
options.push_back ("yes");
options.push_back ("no");
std::string answer; std::string answer;
std::vector <std::string> matches;
do do
{ {
std::cout << question std::cout << question
<< " (y/n) "; << STRING_UTIL_CONFIRM_YN;
std::getline (std::cin, answer); std::getline (std::cin, answer);
answer = std::cin.eof() ? "no" : lowerCase (trim (answer)); answer = std::cin.eof() ? STRING_UTIL_CONFIRM_NO : lowerCase (trim (answer));
}
while (answer != "y" && // TODO i18n
answer != "ye" && // TODO i18n
answer != "yes" && // TODO i18n
answer != "n" && // TODO i18n
answer != "no"); // TODO i18n
return (answer == "y" || answer == "ye" || answer == "yes") ? true : false; // TODO i18n autoComplete (answer, options, matches);
}
while (matches.size () != 1);
return matches[0] == STRING_UTIL_CONFIRM_YES ? true : false;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -83,11 +89,11 @@ bool confirm (const std::string& question)
int confirm3 (const std::string& question) int confirm3 (const std::string& question)
{ {
std::vector <std::string> options; std::vector <std::string> options;
options.push_back ("Yes"); options.push_back (STRING_UTIL_CONFIRM_YES_U);
options.push_back ("yes"); options.push_back (STRING_UTIL_CONFIRM_YES);
options.push_back ("no"); options.push_back (STRING_UTIL_CONFIRM_NO);
options.push_back ("All"); options.push_back (STRING_UTIL_CONFIRM_ALL_U);
options.push_back ("all"); options.push_back (STRING_UTIL_CONFIRM_ALL);
std::string answer; std::string answer;
std::vector <std::string> matches; std::vector <std::string> matches;
@ -107,10 +113,10 @@ int confirm3 (const std::string& question)
} }
while (matches.size () != 1); while (matches.size () != 1);
if (matches[0] == "Yes") return 1; if (matches[0] == STRING_UTIL_CONFIRM_YES_U) return 1;
else if (matches[0] == "yes") return 1; else if (matches[0] == STRING_UTIL_CONFIRM_YES) return 1;
else if (matches[0] == "All") return 2; else if (matches[0] == STRING_UTIL_CONFIRM_ALL_U) return 2;
else if (matches[0] == "all") return 2; else if (matches[0] == STRING_UTIL_CONFIRM_ALL) return 2;
else return 0; else return 0;
} }
@ -122,12 +128,12 @@ int confirm3 (const std::string& question)
int confirm4 (const std::string& question) int confirm4 (const std::string& question)
{ {
std::vector <std::string> options; std::vector <std::string> options;
options.push_back ("Yes"); options.push_back (STRING_UTIL_CONFIRM_YES_U);
options.push_back ("yes"); options.push_back (STRING_UTIL_CONFIRM_YES);
options.push_back ("no"); options.push_back (STRING_UTIL_CONFIRM_NO);
options.push_back ("All"); options.push_back (STRING_UTIL_CONFIRM_ALL_U);
options.push_back ("all"); options.push_back (STRING_UTIL_CONFIRM_ALL);
options.push_back ("quit"); options.push_back (STRING_UTIL_CONFIRM_QUIT);
std::string answer; std::string answer;
std::vector <std::string> matches; std::vector <std::string> matches;
@ -148,11 +154,11 @@ int confirm4 (const std::string& question)
} }
while (matches.size () != 1); while (matches.size () != 1);
if (matches[0] == "Yes") return 1; if (matches[0] == STRING_UTIL_CONFIRM_YES_U) return 1;
else if (matches[0] == "yes") return 1; else if (matches[0] == STRING_UTIL_CONFIRM_YES) return 1;
else if (matches[0] == "All") return 2; else if (matches[0] == STRING_UTIL_CONFIRM_ALL_U) return 2;
else if (matches[0] == "all") return 2; else if (matches[0] == STRING_UTIL_CONFIRM_ALL) return 2;
else if (matches[0] == "quit") return 3; else if (matches[0] == STRING_UTIL_CONFIRM_QUIT) return 3;
else return 0; else return 0;
} }
@ -172,10 +178,10 @@ std::string formatBytes (size_t bytes)
{ {
char formatted[24]; char formatted[24];
if (bytes >= 995000000) sprintf (formatted, "%.1f GiB", (bytes / 1000000000.0)); if (bytes >= 995000000) sprintf (formatted, "%.1f %s", (bytes / 1000000000.0), STRING_UTIL_GIBIBYTES);
else if (bytes >= 995000) sprintf (formatted, "%.1f MiB", (bytes / 1000000.0)); else if (bytes >= 995000) sprintf (formatted, "%.1f %s", (bytes / 1000000.0), STRING_UTIL_MEBIBYTES);
else if (bytes >= 995) sprintf (formatted, "%.1f KiB", (bytes / 1000.0)); else if (bytes >= 995) sprintf (formatted, "%.1f %s", (bytes / 1000.0), STRING_UTIL_KIBIBYTES);
else sprintf (formatted, "%d B", (int)bytes ); else sprintf (formatted, "%d %s", (int)bytes, STRING_UTIL_BYTES);
return commify (formatted); return commify (formatted);
} }
@ -237,7 +243,7 @@ const std::string uuid ()
#include <stdlib.h> #include <stdlib.h>
static char randomHexDigit () static char randomHexDigit ()
{ {
static char digits[] = "0123456789abcdef"; // no i18n static char digits[] = "0123456789abcdef"; // no l10n
#ifdef HAVE_RANDOM #ifdef HAVE_RANDOM
// random is better than rand. // random is better than rand.
return digits[random () % 16]; return digits[random () % 16];