diff --git a/src/DOM.cpp b/src/DOM.cpp index b1e7b38e1..916ea83d4 100644 --- a/src/DOM.cpp +++ b/src/DOM.cpp @@ -25,6 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include @@ -132,7 +134,7 @@ const std::string DOM::get (const std::string& name) } else - throw std::string ("DOM: Cannot get unrecognized name '") + name + "'."; + throw format (STRING_DOM_UNREC, name); } // . @@ -152,6 +154,11 @@ const std::string DOM::get (const std::string& name) // TODO . else if (n.getUUID (uuid)) { + std::string attr; + if (n.skip ('.') && + n.getUntilEOS (attr)) + { + } } // TODO report. @@ -192,7 +199,7 @@ const std::string DOM::get (const std::string& name) #endif else - throw std::string ("DOM: Cannot get unrecognized name '") + name + "'."; + throw format (STRING_DOM_UNREC, name); } return ""; @@ -212,7 +219,7 @@ void DOM::set (const std::string& name, const std::string& value) // Unrecognized --> error. else - throw std::string ("DOM: Cannot set '") + name + "'."; + throw format (STRING_DOM_CANNOT_SET, name); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColDue.cpp b/src/columns/ColDue.cpp index 0512be23e..46a2dade1 100644 --- a/src/columns/ColDue.cpp +++ b/src/columns/ColDue.cpp @@ -25,19 +25,22 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include #include #include #include +#include extern Context context; //////////////////////////////////////////////////////////////////////////////// ColumnDue::ColumnDue () { - _label = "Due"; + _label = STRING_COLUMN_LABEL_DUE; _attribute = "due"; } @@ -53,8 +56,8 @@ void ColumnDue::setStyle (const std::string& value) { _style = value; - if (_style == "countdown" && _label == "Due") - _label = "Countdown"; + if (_style == "countdown" && _label == STRING_COLUMN_LABEL_DUE) + _label = STRING_COLUMN_LABEL_COUNT; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColEnd.cpp b/src/columns/ColEnd.cpp index cac405351..cd9bcde5c 100644 --- a/src/columns/ColEnd.cpp +++ b/src/columns/ColEnd.cpp @@ -25,12 +25,15 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include +#include //////////////////////////////////////////////////////////////////////////////// ColumnEnd::ColumnEnd () { - _label = "Completed"; + _label = STRING_COLUMN_LABEL_COMPLETE; _attribute = "end"; } diff --git a/src/columns/ColEntry.cpp b/src/columns/ColEntry.cpp index 8eac52cf7..166c1a2dd 100644 --- a/src/columns/ColEntry.cpp +++ b/src/columns/ColEntry.cpp @@ -25,12 +25,15 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include +#include //////////////////////////////////////////////////////////////////////////////// ColumnEntry::ColumnEntry () { - _label = "Added"; + _label = STRING_COLUMN_LABEL_ADDED; _attribute = "entry"; } @@ -46,7 +49,9 @@ void ColumnEntry::setStyle (const std::string& value) { _style = value; - if (_style == "age" && _label == "Added") _label = "Age"; + if (_style == "age" && + _label == STRING_COLUMN_LABEL_ADDED) + _label = STRING_COLUMN_LABEL_AGE; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColID.cpp b/src/columns/ColID.cpp index 10fdb8c3a..e8186686d 100644 --- a/src/columns/ColID.cpp +++ b/src/columns/ColID.cpp @@ -25,10 +25,13 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include #include +#include extern Context context; @@ -37,7 +40,7 @@ ColumnID::ColumnID () { _type = "number"; _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; if (_style != "default") - throw std::string ("Unrecognized column format 'id.") + _style + "'"; + throw format (STRING_COLUMN_BAD_FORMAT, "id", _style); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColPriority.cpp b/src/columns/ColPriority.cpp index 9fa9d2ce4..07fc91da1 100644 --- a/src/columns/ColPriority.cpp +++ b/src/columns/ColPriority.cpp @@ -25,9 +25,12 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include +#include extern Context context; @@ -36,7 +39,7 @@ ColumnPriority::ColumnPriority () { _type = "string"; _style = "default"; - _label = "Pri"; + _label = STRING_COLUMN_LABEL_PRI; } //////////////////////////////////////////////////////////////////////////////// @@ -51,8 +54,8 @@ void ColumnPriority::setStyle (const std::string& value) { _style = value; - if (_style == "long" && _label == "Pri") - _label = "Priority"; + if (_style == "long" && _label == STRING_COLUMN_LABEL_PRI) + _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 (_style != "default") - throw std::string ("Unrecognized column format 'priority.") + _style + "'"; + throw format (STRING_COLUMN_BAD_FORMAT, "priority", _style); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColProject.cpp b/src/columns/ColProject.cpp index 3874e8708..a73e75d7f 100644 --- a/src/columns/ColProject.cpp +++ b/src/columns/ColProject.cpp @@ -25,9 +25,12 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include +#include extern Context context; @@ -36,7 +39,7 @@ ColumnProject::ColumnProject () { _type = "string"; _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); } else if (_style != "default") - throw std::string ("Unrecognized column format 'project.") + _style + "'"; + throw format (STRING_COLUMN_BAD_FORMAT, "project.", _style); minimum = longestWord (project); maximum = project.length (); diff --git a/src/columns/ColRecur.cpp b/src/columns/ColRecur.cpp index 979998844..a473af3cd 100644 --- a/src/columns/ColRecur.cpp +++ b/src/columns/ColRecur.cpp @@ -25,9 +25,12 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include +#include extern Context context; @@ -36,7 +39,7 @@ ColumnRecur::ColumnRecur () { _type = "string"; _style = "default"; - _label = "Recur"; + _label = STRING_COLUMN_LABEL_RECUR; } //////////////////////////////////////////////////////////////////////////////// @@ -51,7 +54,7 @@ void ColumnRecur::setStyle (const std::string& 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 ()); } @@ -69,7 +72,7 @@ void ColumnRecur::measure (Task& task, int& minimum, int& maximum) minimum = maximum = context.config.get ("recurrence.indicator").length (); } else - throw std::string ("Unrecognized column format 'recur.") + _style + "'"; + throw format (STRING_COLUMN_BAD_FORMAT, "recur.", _style); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColStart.cpp b/src/columns/ColStart.cpp index 64985dfd7..c82628095 100644 --- a/src/columns/ColStart.cpp +++ b/src/columns/ColStart.cpp @@ -25,16 +25,19 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include +#include extern Context context; //////////////////////////////////////////////////////////////////////////////// ColumnStart::ColumnStart () { - _label = "Started"; + _label = STRING_COLUMN_LABEL_STARTED; _attribute = "start"; } @@ -50,8 +53,8 @@ void ColumnStart::setStyle (const std::string& value) { _style = value; - if (_style == "active" && _label == "Started") - _label = "A"; + if (_style == "active" && _label == STRING_COLUMN_LABEL_STARTED) + _label = STRING_COLUMN_LABEL_ACTIVE; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColStatus.cpp b/src/columns/ColStatus.cpp index ccf26ffe0..3a0e46bb5 100644 --- a/src/columns/ColStatus.cpp +++ b/src/columns/ColStatus.cpp @@ -25,9 +25,12 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include +#include extern Context context; @@ -36,7 +39,7 @@ ColumnStatus::ColumnStatus () { _type = "string"; _style = "default"; - _label = "Status"; + _label = STRING_COLUMN_LABEL_STATUS; } //////////////////////////////////////////////////////////////////////////////// @@ -51,8 +54,8 @@ void ColumnStatus::setStyle (const std::string& value) { _style = value; - if (_style == "short" && _label == "Status") - _label = "St"; + if (_style == "short" && _label == STRING_COLUMN_LABEL_STATUS) + _label = STRING_COLUMN_LABEL_STAT; } //////////////////////////////////////////////////////////////////////////////// @@ -78,7 +81,7 @@ void ColumnStatus::measure (Task& task, int& minimum, int& maximum) else if (_style == "short") minimum = maximum = 1; 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 (status == Task::pending) value = "Pending"; - else if (status == Task::completed) value = "Completed"; - else if (status == Task::deleted) value = "Deleted"; - else if (status == Task::waiting) value = "Waiting"; - else if (status == Task::recurring) value = "Recurring"; + if (status == Task::pending) value = STRING_COLUMN_LABEL_STAT_PE; + else if (status == Task::completed) value = STRING_COLUMN_LABEL_STAT_CO; + else if (status == Task::deleted) value = STRING_COLUMN_LABEL_STAT_DE; + else if (status == Task::waiting) value = STRING_COLUMN_LABEL_STAT_WA; + else if (status == Task::recurring) value = STRING_COLUMN_LABEL_STAT_RE; } else if (_style == "short") { - if (status == Task::pending) value = "P"; - else if (status == Task::completed) value = "C"; - else if (status == Task::deleted) value = "D"; - else if (status == Task::waiting) value = "W"; - else if (status == Task::recurring) value = "R"; + if (status == Task::pending) value = STRING_COLUMN_LABEL_STAT_P; + else if (status == Task::completed) value = STRING_COLUMN_LABEL_STAT_C; + else if (status == Task::deleted) value = STRING_COLUMN_LABEL_STAT_D; + else if (status == Task::waiting) value = STRING_COLUMN_LABEL_STAT_W; + else if (status == Task::recurring) value = STRING_COLUMN_LABEL_STAT_R; } lines.push_back (color.colorize (leftJustify (value, width))); diff --git a/src/columns/ColString.cpp b/src/columns/ColString.cpp index 6ba1c4ec0..adb264d95 100644 --- a/src/columns/ColString.cpp +++ b/src/columns/ColString.cpp @@ -25,9 +25,12 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include +#include extern Context context; @@ -69,7 +72,7 @@ void ColumnString::measure (const std::string& value, int& minimum, int& maximum _style == "right_fixed") minimum = maximum = strippedLength (value); else - throw std::string ("Unrecognized column format 'string.") + _style + "'"; + throw format (STRING_COLUMN_BAD_FORMAT, "string.", _style); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColTags.cpp b/src/columns/ColTags.cpp index 240bab840..c7aa97024 100644 --- a/src/columns/ColTags.cpp +++ b/src/columns/ColTags.cpp @@ -25,10 +25,13 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include #include +#include extern Context context; @@ -37,7 +40,7 @@ ColumnTags::ColumnTags () { _type = "string"; _style = "default"; - _label = "Tags"; + _label = STRING_COLUMN_LABEL_TAGS; } //////////////////////////////////////////////////////////////////////////////// @@ -52,8 +55,13 @@ void ColumnTags::setStyle (const std::string& value) { _style = value; - if (_style == "indicator" && _label == "Tags") _label = _label.substr (0, context.config.get ("tag.indicator").length ()); - else if (_style == "count" && _label == "Tags") _label = "Tag"; + if (_style == "indicator" && + _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 - throw std::string ("Unrecognized column format 'tags.") + _style + "'"; - + throw format (STRING_COLUMN_BAD_FORMAT, "tags.", _style); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColUUID.cpp b/src/columns/ColUUID.cpp index f7029b797..35e8dacd2 100644 --- a/src/columns/ColUUID.cpp +++ b/src/columns/ColUUID.cpp @@ -25,10 +25,13 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include #include +#include extern Context context; @@ -37,7 +40,7 @@ ColumnUUID::ColumnUUID () { _type = "string"; _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; else if (_style == "short") minimum = maximum = 8; else - throw std::string ("Unrecognized column format 'uuid.") + _style + "'"; + throw format (STRING_COLUMN_BAD_FORMAT, "uuid.", _style); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColUntil.cpp b/src/columns/ColUntil.cpp index d83443663..177ead8c1 100644 --- a/src/columns/ColUntil.cpp +++ b/src/columns/ColUntil.cpp @@ -25,12 +25,15 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include +#include //////////////////////////////////////////////////////////////////////////////// ColumnUntil::ColumnUntil () { - _label = "Until"; + _label = STRING_COLUMN_LABEL_UNTIL; _attribute = "until"; } diff --git a/src/columns/ColUrgency.cpp b/src/columns/ColUrgency.cpp index 73fef70ca..64b2337f0 100644 --- a/src/columns/ColUrgency.cpp +++ b/src/columns/ColUrgency.cpp @@ -25,9 +25,12 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include +#include extern Context context; @@ -36,7 +39,7 @@ ColumnUrgency::ColumnUrgency () { _type = "number"; _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 (); if (_style != "default") - throw std::string ("Unrecognized column format 'urgency.") + _style + "'"; + throw format (STRING_COLUMN_BAD_FORMAT, "urgency.", _style); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/columns/ColWait.cpp b/src/columns/ColWait.cpp index 5bc9cc767..44460bf13 100644 --- a/src/columns/ColWait.cpp +++ b/src/columns/ColWait.cpp @@ -25,12 +25,15 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include +#include //////////////////////////////////////////////////////////////////////////////// ColumnWait::ColumnWait () { - _label = "Wait"; + _label = STRING_COLUMN_LABEL_WAIT; _attribute = "wait"; } diff --git a/src/columns/Column.cpp b/src/columns/Column.cpp index 9fcc32391..c26b49e4e 100644 --- a/src/columns/Column.cpp +++ b/src/columns/Column.cpp @@ -25,6 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include @@ -45,6 +47,7 @@ #include #include #include +#include extern Context context; @@ -91,7 +94,7 @@ Column* Column::factory (const std::string& name, const std::string& report) // Special non-task column else if (column_name == "string") column = new ColumnString (); else - throw std::string ("Unrecognized column name '") + column_name + "'."; + throw format (STRING_COLUMN_BAD_NAME, column_name); column->setReport (report); column->setStyle (column_style); @@ -174,24 +177,28 @@ void Column::renderHeader ( } //////////////////////////////////////////////////////////////////////////////// +// No L10N. void Column::measure (const std::string&, int&, int&) { throw std::string ("Virtual method Column::measure not overriden."); } //////////////////////////////////////////////////////////////////////////////// +// No L10N. void Column::measure (Task&, int&, int&) { throw std::string ("Virtual method Column::measure not overriden."); } //////////////////////////////////////////////////////////////////////////////// +// No L10N. void Column::render (std::vector &, const std::string&, int, Color&) { throw std::string ("Virtual method Column::render not overriden."); } //////////////////////////////////////////////////////////////////////////////// +// No L10N. void Column::render (std::vector &, Task&, int, Color&) { throw std::string ("Virtual method Column::render not overriden."); diff --git a/src/commands/CmdCustom.cpp b/src/commands/CmdCustom.cpp index 14b18c8db..e7dba60a7 100644 --- a/src/commands/CmdCustom.cpp +++ b/src/commands/CmdCustom.cpp @@ -104,7 +104,7 @@ int CmdCustom::execute (std::string& output) std::cout << "# tasks=" << tasks.size () << "\n" << "# filtered=" << filtered.size () << "\n"; -return 0; +//return 0; //////////////////////////////////// diff --git a/src/commands/CmdLogo.cpp b/src/commands/CmdLogo.cpp index f6d06c49e..eed622afb 100644 --- a/src/commands/CmdLogo.cpp +++ b/src/commands/CmdLogo.cpp @@ -25,9 +25,12 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include +#include extern Context context; @@ -36,7 +39,7 @@ CmdLogo::CmdLogo () { _keyword = "logo"; _usage = "task logo"; - _description = "Displays the Taskwarrior logo"; + _description = STRING_CMD_LOGO_USAGE; _read_only = true; _displays_id = false; } @@ -83,7 +86,7 @@ int CmdLogo::execute (std::string& output) }; 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"), ' '); output += optionalBlankLine (); diff --git a/src/commands/CmdVersion.cpp b/src/commands/CmdVersion.cpp index 9460c593f..1a228f2ec 100644 --- a/src/commands/CmdVersion.cpp +++ b/src/commands/CmdVersion.cpp @@ -25,6 +25,8 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include #include @@ -32,6 +34,8 @@ #include #include #include +#include +#include extern Context context; @@ -40,7 +44,7 @@ CmdVersion::CmdVersion () { _keyword = "version"; _usage = "task version"; - _description = "Shows the taskwarrior version number."; + _description = STRING_CMD_VERSION_USAGE; _read_only = true; _displays_id = false; } @@ -55,26 +59,20 @@ int CmdVersion::execute (std::string& output) ViewText disclaimer; disclaimer.width (width); disclaimer.add (Column::factory ("string", "")); - disclaimer.set (disclaimer.addRow (), 0, - "Taskwarrior may be copied only under the terms of the GNU General Public " - "License, which may be found in the taskwarrior source kit."); + disclaimer.set (disclaimer.addRow (), 0, STRING_CMD_VERSION_GPL); // Create a table for the URL. ViewText link; link.width (width); link.add (Column::factory ("string", "")); - link.set (link.addRow (), 0, - "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"); + link.set (link.addRow (), 0, STRING_CMD_VERSION_DOCS); Color bold ("bold"); out << "\n" - << (context.color () ? bold.colorize (PACKAGE) : PACKAGE) - << " " - << (context.color () ? bold.colorize (VERSION) : VERSION) - << " built for " + << format (STRING_CMD_VERSION_BUILT, + (context.color () ? bold.colorize (PACKAGE) : PACKAGE), + (context.color () ? bold.colorize (VERSION) : VERSION)) #if defined (DARWIN) << "darwin" @@ -91,11 +89,7 @@ int CmdVersion::execute (std::string& output) #elif defined (LINUX) << "linux" #else - << "unknown" -#endif - -#ifdef HAVE_LIBREADLINE - << "-readline" + << STRING_CMD_VERSION_UNKNOWN #endif #ifdef HAVE_LIBLUA @@ -103,9 +97,11 @@ int CmdVersion::execute (std::string& output) #endif << "\n" - << "Copyright (C) 2006 - 2011 P. Beckingham, F. Hernandez.\n" + << STRING_CMD_VERSION_COPY + << "\n" #ifdef HAVE_LIBLUA - << "Portions of this software Copyright (C) 1994 – 2008 Lua.org, PUC-Rio.\n" + << STRING_CMD_VERSION_COPY2 + << "\n" #endif << "\n" << disclaimer.render () @@ -122,7 +118,7 @@ CmdCompletionVersion::CmdCompletionVersion () { _keyword = "_version"; _usage = "task _version"; - _description = "Shows only the taskwarrior version number."; + _description = STRING_CMD_VERSION_USAGE2; _read_only = true; _displays_id = false; } diff --git a/src/en-US.h b/src/en-US.h index f46641ade..3c346ed58 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -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: -// - text output that the user sees or types +// - text output that the user sees // // Strings that should NOT be localized: // - ./taskrc configuration variable names @@ -38,12 +43,13 @@ // - debug strings // - attribute names // - modifier names +// - logical operators (and, or, xor) // // Rules: // - Localized strings should contain leading or trailing white space, // including \n, thus allowing the code to compose strings. // - 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 . // make // -// 5. Submit your translation to support@taskwarrior.org, for inclusion in -// next release. +// 5. Submit your translation to support@taskwarrior.org, where it will be +// shared with others. // //////////////////////////////////////////////////////////////////////////////// #ifndef INCLUDED_STRINGS #define INCLUDED_STRINGS +#define L10N // Localization complete. // API #define STRING_API_EXITING "Exiting." @@ -95,11 +102,54 @@ #define STRING_API_WARNING "Warning: {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_LABEL_DEP "Depends" #define STRING_COLUMN_LABEL_DEP_S "Dep" #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 #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 "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 diff --git a/src/util.cpp b/src/util.cpp index 86068b95e..5ec08c462 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -24,6 +24,9 @@ // USA // //////////////////////////////////////////////////////////////////////////////// + +#define L10N // Localization complete. + #include #include #include @@ -57,23 +60,26 @@ extern Context context; // std::getline, the newline can be detected, and the prompt re-written. bool confirm (const std::string& question) { + std::vector options; + options.push_back ("yes"); + options.push_back ("no"); + std::string answer; + std::vector matches; do { std::cout << question - << " (y/n) "; + << STRING_UTIL_CONFIRM_YN; std::getline (std::cin, answer); - answer = std::cin.eof() ? "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 + answer = std::cin.eof() ? STRING_UTIL_CONFIRM_NO : lowerCase (trim (answer)); - 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) { std::vector options; - options.push_back ("Yes"); - options.push_back ("yes"); - options.push_back ("no"); - options.push_back ("All"); - options.push_back ("all"); + options.push_back (STRING_UTIL_CONFIRM_YES_U); + options.push_back (STRING_UTIL_CONFIRM_YES); + options.push_back (STRING_UTIL_CONFIRM_NO); + options.push_back (STRING_UTIL_CONFIRM_ALL_U); + options.push_back (STRING_UTIL_CONFIRM_ALL); std::string answer; std::vector matches; @@ -107,11 +113,11 @@ int confirm3 (const std::string& question) } while (matches.size () != 1); - if (matches[0] == "Yes") return 1; - else if (matches[0] == "yes") return 1; - else if (matches[0] == "All") return 2; - else if (matches[0] == "all") return 2; - else return 0; + if (matches[0] == STRING_UTIL_CONFIRM_YES_U) return 1; + else if (matches[0] == STRING_UTIL_CONFIRM_YES) return 1; + else if (matches[0] == STRING_UTIL_CONFIRM_ALL_U) return 2; + else if (matches[0] == STRING_UTIL_CONFIRM_ALL) return 2; + else return 0; } //////////////////////////////////////////////////////////////////////////////// @@ -122,12 +128,12 @@ int confirm3 (const std::string& question) int confirm4 (const std::string& question) { std::vector options; - options.push_back ("Yes"); - options.push_back ("yes"); - options.push_back ("no"); - options.push_back ("All"); - options.push_back ("all"); - options.push_back ("quit"); + options.push_back (STRING_UTIL_CONFIRM_YES_U); + options.push_back (STRING_UTIL_CONFIRM_YES); + options.push_back (STRING_UTIL_CONFIRM_NO); + options.push_back (STRING_UTIL_CONFIRM_ALL_U); + options.push_back (STRING_UTIL_CONFIRM_ALL); + options.push_back (STRING_UTIL_CONFIRM_QUIT); std::string answer; std::vector matches; @@ -148,11 +154,11 @@ int confirm4 (const std::string& question) } while (matches.size () != 1); - if (matches[0] == "Yes") return 1; - else if (matches[0] == "yes") return 1; - else if (matches[0] == "All") return 2; - else if (matches[0] == "all") return 2; - else if (matches[0] == "quit") return 3; + if (matches[0] == STRING_UTIL_CONFIRM_YES_U) return 1; + else if (matches[0] == STRING_UTIL_CONFIRM_YES) return 1; + else if (matches[0] == STRING_UTIL_CONFIRM_ALL_U) return 2; + else if (matches[0] == STRING_UTIL_CONFIRM_ALL) return 2; + else if (matches[0] == STRING_UTIL_CONFIRM_QUIT) return 3; else return 0; } @@ -172,10 +178,10 @@ std::string formatBytes (size_t bytes) { char formatted[24]; - if (bytes >= 995000000) sprintf (formatted, "%.1f GiB", (bytes / 1000000000.0)); - else if (bytes >= 995000) sprintf (formatted, "%.1f MiB", (bytes / 1000000.0)); - else if (bytes >= 995) sprintf (formatted, "%.1f KiB", (bytes / 1000.0)); - else sprintf (formatted, "%d B", (int)bytes ); + if (bytes >= 995000000) sprintf (formatted, "%.1f %s", (bytes / 1000000000.0), STRING_UTIL_GIBIBYTES); + else if (bytes >= 995000) sprintf (formatted, "%.1f %s", (bytes / 1000000.0), STRING_UTIL_MEBIBYTES); + else if (bytes >= 995) sprintf (formatted, "%.1f %s", (bytes / 1000.0), STRING_UTIL_KIBIBYTES); + else sprintf (formatted, "%d %s", (int)bytes, STRING_UTIL_BYTES); return commify (formatted); } @@ -237,7 +243,7 @@ const std::string uuid () #include static char randomHexDigit () { - static char digits[] = "0123456789abcdef"; // no i18n + static char digits[] = "0123456789abcdef"; // no l10n #ifdef HAVE_RANDOM // random is better than rand. return digits[random () % 16];