- Localized more files.
This commit is contained in:
Paul Beckingham 2011-06-21 18:05:17 -04:00
parent 393ebae8aa
commit b63835757f
12 changed files with 81 additions and 37 deletions

View file

@ -24,6 +24,9 @@
// USA // USA
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
@ -150,7 +153,7 @@ Color::Color (const std::string& spec)
{ {
index = atoi (word.substr (4).c_str ()); index = atoi (word.substr (4).c_str ());
if (index < 0 || index > 23) if (index < 0 || index > 23)
throw std::string ("The color '") + *it + "' is not recognized."; throw format (STRING_COLOR_UNRECOGNIZED, *it);
if (bg) if (bg)
{ {
@ -172,7 +175,7 @@ Color::Color (const std::string& spec)
index = atoi (word.substr (3).c_str ()); index = atoi (word.substr (3).c_str ());
if (word.length () != 6 || if (word.length () != 6 ||
index < 0 || index > 555) index < 0 || index > 555)
throw std::string ("The color '") + *it + "' is not recognized."; throw format (STRING_COLOR_UNRECOGNIZED, *it);
int r = atoi (word.substr (3, 1).c_str ()); int r = atoi (word.substr (3, 1).c_str ());
int g = atoi (word.substr (4, 1).c_str ()); int g = atoi (word.substr (4, 1).c_str ());
@ -180,7 +183,7 @@ Color::Color (const std::string& spec)
if (r < 0 || r > 5 || if (r < 0 || r > 5 ||
g < 0 || g > 5 || g < 0 || g > 5 ||
b < 0 || b > 5) b < 0 || b > 5)
throw std::string ("The color '") + *it + "' is not recognized."; throw format (STRING_COLOR_UNRECOGNIZED, *it);
index = 16 + r*36 + g*6 + b; index = 16 + r*36 + g*6 + b;
@ -203,7 +206,7 @@ Color::Color (const std::string& spec)
{ {
index = atoi (word.substr (5).c_str ()); index = atoi (word.substr (5).c_str ());
if (index < 0 || index > 255) if (index < 0 || index > 255)
throw std::string ("The color '") + *it + "' is not recognized."; throw format (STRING_COLOR_UNRECOGNIZED, *it);
upgrade (); upgrade ();
@ -221,7 +224,7 @@ Color::Color (const std::string& spec)
} }
} }
else if (word != "") else if (word != "")
throw std::string ("The color '") + *it + "' is not recognized."; throw format (STRING_COLOR_UNRECOGNIZED, *it);
} }
// Now combine the fg and bg into a single color. // Now combine the fg and bg into a single color.

View file

@ -29,8 +29,11 @@
#include <Permission.h> #include <Permission.h>
#include <Context.h> #include <Context.h>
#include <util.h> #include <util.h>
#include <text.h>
#include <i18n.h> #include <i18n.h>
#define L10N // Localization complete.
extern Context context; extern Context context;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -56,16 +59,14 @@ bool Permission::confirmed (const Task& task, const std::string& question)
if (allConfirmed) if (allConfirmed)
return true; return true;
std::cout << "\nTask " std::cout << "\n"
<< task.id << format (STRING_PERM_TASK_LINE, task.id, task.get ("description"));
<< " \""
<< task.get ("description")
<< "\"";
if (task.getStatus () == Task::recurring || if (task.getStatus () == Task::recurring ||
task.has ("parent")) task.has ("parent"))
{ {
std::cout << " (Recurring)"; std::cout << " "
<< STRING_PERM_RECURRING;
} }
std::cout << std::endl; // Flush. std::cout << std::endl; // Flush.

View file

@ -25,8 +25,11 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
#include <i18n.h>
#include <assert.h> #include <assert.h>
#include <Taskmod.h> #include <Taskmod.h>
@ -130,9 +133,7 @@ bool Taskmod::isValid ()
std::string Taskmod::getUuid () std::string Taskmod::getUuid ()
{ {
if (!bAfterSet) if (!bAfterSet)
{ throw std::string (STRING_TASKMOD_BAD_INIT);
throw std::string ("Taskmod::getUuid(): Task object not initialized.");
}
return after.get ("uuid"); return after.get ("uuid");
} }
@ -143,14 +144,14 @@ std::string Taskmod::toString ()
assert (bAfterSet); assert (bAfterSet);
std::stringstream stream; std::stringstream stream;
stream << "time " << timestamp << "\n"; stream << STRING_TASKMOD_TIME << timestamp << "\n";
if (bBeforeSet) if (bBeforeSet)
{ {
stream << "old " << before.composeF4(); stream << STRING_TASKMOD_OLD << before.composeF4();
} }
stream << "new " << after.composeF4(); stream << STRING_TASKMOD_NEW << after.composeF4();
stream << "---\n"; stream << "---\n";
return stream.str (); return stream.str ();
@ -202,3 +203,5 @@ std::string Taskmod::getTimeStr () const
return sstream.str (); return sstream.str ();
} }
////////////////////////////////////////////////////////////////////////////////

View file

@ -25,6 +25,8 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <iostream> #include <iostream>
#include <stdlib.h> #include <stdlib.h>
#include <util.h> #include <util.h>

View file

@ -25,7 +25,11 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <Context.h> #include <Context.h>
#include <text.h>
#include <i18n.h>
#include <Uri.h> #include <Uri.h>
extern Context context; extern Context context;
@ -231,7 +235,7 @@ void Uri::parse ()
} }
else else
{ {
throw std::string ("Could not parse uri '") + data + "', wrong usage of single quotes."; throw std::string (format (STRING_URI_QUOTES, data));
} }
} }
else else
@ -252,7 +256,7 @@ void Uri::parse ()
} }
else else
{ {
throw std::string ("The uri '") + data + "' is not in the expected format."; throw std::string (format (STRING_URI_BAD_FORMAT, data));
} }
// path is absolute for ssh:// syntax // path is absolute for ssh:// syntax

View file

@ -25,6 +25,8 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <ViewTask.h> #include <ViewTask.h>
#include <Context.h> #include <Context.h>
#include <Timer.h> #include <Timer.h>
@ -104,8 +106,6 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
// Determine minimal, ideal column widths. // Determine minimal, ideal column widths.
std::vector <int> minimal; std::vector <int> minimal;
std::vector <int> ideal; std::vector <int> ideal;
// std::vector <int> avg_ideal;
// int cumulative_ideal = 0;
std::vector <Column*>::iterator i; std::vector <Column*>::iterator i;
for (i = _columns.begin (); i != _columns.end (); ++i) for (i = _columns.begin (); i != _columns.end (); ++i)
@ -129,17 +129,10 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
if (min > global_min) global_min = min; if (min > global_min) global_min = min;
if (ideal > global_ideal) global_ideal = ideal; if (ideal > global_ideal) global_ideal = ideal;
// cumulative_ideal += ideal;
} }
minimal.push_back (global_min); minimal.push_back (global_min);
ideal.push_back (global_ideal); ideal.push_back (global_ideal);
// if (data.size ())
// avg_ideal.push_back ((int) (cumulative_ideal / data.size ()));
// else
// avg_ideal.push_back (0);
} }
// Sum the minimal widths. // Sum the minimal widths.
@ -163,7 +156,6 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
if (_width == 0 || sum_ideal <= overage) if (_width == 0 || sum_ideal <= overage)
widths = ideal; widths = ideal;
else if (sum_minimal > overage || overage < 0) else if (sum_minimal > overage || overage < 0)
// throw std::string ("There is not enough horizontal width to display the results.");
widths = minimal; widths = minimal;
else if (overage > 0) else if (overage > 0)
{ {

View file

@ -25,6 +25,8 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <ViewText.h> #include <ViewText.h>
#include <Context.h> #include <Context.h>
#include <Timer.h> #include <Timer.h>
@ -152,7 +154,6 @@ std::string ViewText::render ()
if (sum_ideal <= overage) if (sum_ideal <= overage)
widths = ideal; widths = ideal;
else if (sum_minimal > overage || overage < 0) else if (sum_minimal > overage || overage < 0)
// throw std::string ("There is not enough horizontal width to display the results.");
widths = minimal; widths = minimal;
else if (overage > 0) else if (overage > 0)
{ {

View file

@ -25,8 +25,11 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <stdlib.h> #include <stdlib.h>
#include <Context.h> #include <Context.h>
#include <i18n.h>
#include <CmdExec.h> #include <CmdExec.h>
extern Context context; extern Context context;
@ -36,7 +39,7 @@ CmdExec::CmdExec ()
{ {
_keyword = "execute"; _keyword = "execute";
_usage = "task execute <external command>"; _usage = "task execute <external command>";
_description = "Executes external commands and scripts"; _description = STRING_CMD_EXEC_USAGE;
_read_only = false; _read_only = false;
_displays_id = true; _displays_id = true;
} }

View file

@ -25,10 +25,14 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define L10N // Localization complete.
#include <sstream> #include <sstream>
#include <stdlib.h> #include <stdlib.h>
#include <Context.h> #include <Context.h>
#include <main.h> #include <main.h>
#include <text.h>
#include <i18n.h>
#include <CmdUrgency.h> #include <CmdUrgency.h>
extern Context context; extern Context context;
@ -38,7 +42,7 @@ CmdUrgency::CmdUrgency ()
{ {
_keyword = "_urgency"; _keyword = "_urgency";
_usage = "task _urgency <IDs>"; _usage = "task _urgency <IDs>";
_description = "Displays the urgency measure of a task."; _description = STRING_CMD_URGENCY_USAGE;
_read_only = true; _read_only = true;
_displays_id = false; _displays_id = false;
} }
@ -60,7 +64,7 @@ int CmdUrgency::execute (std::string& output)
if (filtered.size () == 0) if (filtered.size () == 0)
{ {
context.footnote ("No tasks specified."); context.footnote (STRING_CMD_URGENCY_NO_TASKS);
return 1; return 1;
} }
@ -68,10 +72,7 @@ int CmdUrgency::execute (std::string& output)
std::stringstream out; std::stringstream out;
std::vector <Task>::iterator task; std::vector <Task>::iterator task;
for (task = filtered.begin (); task != filtered.end (); ++task) for (task = filtered.begin (); task != filtered.end (); ++task)
out << "task " out << format (STRING_CMD_URGENCY_RESULT, task->id, task->urgency ())
<< task->id
<< " urgency "
<< task->urgency ()
<< "\n"; << "\n";
output = out.str (); output = out.str ();

View file

@ -102,6 +102,9 @@
#define STRING_API_WARNING "Warning: {1}" #define STRING_API_WARNING "Warning: {1}"
#define STRING_API_ERROR "Error: {1}" #define STRING_API_ERROR "Error: {1}"
// Color
#define STRING_COLOR_UNRECOGNIZED "The color '{1}' is not recognized."
// columns/Col* // columns/Col*
#define STRING_COLUMN_BAD_NAME "Unrecognized column name '{1}'" #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}'"
@ -150,6 +153,10 @@
#define STRING_CMD_VERSION_COPY2 "Portions of this software Copyright (C) 1994 2008 Lua.org, PUC-Rio." #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_USAGE "Displays the Taskwarrior logo"
#define STRING_CMD_LOGO_COLOR_REQ "The logo command requires that color support is enabled." #define STRING_CMD_LOGO_COLOR_REQ "The logo command requires that color support is enabled."
#define STRING_CMD_EXEC_USAGE "Executes external commands and scripts"
#define STRING_CMD_URGENCY_USAGE "Displays the urgency measure of a task."
#define STRING_CMD_URGENCY_NO_TASKS "No tasks specified."
#define STRING_CMD_URGENCY_RESULT "task {1} urgency {2}"
// 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."
@ -182,6 +189,10 @@
#define STRING_LUA_BAD_HOOK_DEF "Malformed hook definition '{1}'." #define STRING_LUA_BAD_HOOK_DEF "Malformed hook definition '{1}'."
#define STRING_LUA_BAD_EVENT "Unrecognized hook event '{1}'." #define STRING_LUA_BAD_EVENT "Unrecognized hook event '{1}'."
// Permission
#define STRING_PERM_TASK_LINE "task {1} \"{2}\""
#define STRING_PERM_RECURRING "(Recurring)"
// Record // Record
#define STRING_RECORD_EMPTY "Empty record in input." #define STRING_RECORD_EMPTY "Empty record in input."
#define STRING_RECORD_JUNK_AT_EOL "Unrecognized characters at end of line." #define STRING_RECORD_JUNK_AT_EOL "Unrecognized characters at end of line."
@ -202,10 +213,20 @@
#define STRING_CMD_SHOW_CONF_VAR "Config Variable" #define STRING_CMD_SHOW_CONF_VAR "Config Variable"
#define STRING_CMD_SHOW_CONF_VALUE "Value" #define STRING_CMD_SHOW_CONF_VALUE "Value"
// Taskmod
#define STRING_TASKMOD_BAD_INIT "Taskmod::getUuid(): Task object not initialized."
#define STRING_TASKMOD_TIME "time "
#define STRING_TASKMOD_OLD "old "
#define STRING_TASKMOD_NEW "new "
// text // text
// A comma-separated list of commands is appended. // A comma-separated list of commands is appended.
#define STRING_TEXT_AMBIGUOUS "Ambiguous {1} '{2}' - could be either of " #define STRING_TEXT_AMBIGUOUS "Ambiguous {1} '{2}' - could be either of "
// Uri
#define STRING_URI_QUOTES "Could not parse uri '{1}', wrong usage of single quotes."
#define STRING_URI_BAD_FORMAT "The uri '{1}' is not in the expected format."
// utf8 // utf8
#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."

View file

@ -890,6 +890,18 @@ const std::string format (
return output; return output;
} }
////////////////////////////////////////////////////////////////////////////////
const std::string format (
const std::string& fmt,
int arg1,
double arg2)
{
std::string output = fmt;
replace_positional (output, "{1}", format (arg1));
replace_positional (output, "{2}", format (arg2, 6, 3));
return output;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const std::string format ( const std::string format (
const std::string& fmt, const std::string& fmt,

View file

@ -78,6 +78,7 @@ const std::string format (const std::string&, const std::string&, const std::str
const std::string format (const std::string&, const std::string&, int); const std::string format (const std::string&, const std::string&, int);
const std::string format (const std::string&, int, const std::string&); const std::string format (const std::string&, int, const std::string&);
const std::string format (const std::string&, int, int); const std::string format (const std::string&, int, int);
const std::string format (const std::string&, int, double);
const std::string format (const std::string&, const std::string&, const std::string&, const std::string&); const std::string format (const std::string&, const std::string&, const std::string&, const std::string&);
std::string leftJustify (const int, const int); std::string leftJustify (const int, const int);