mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-26 06:37:20 +02:00
I18N
- Localized more commands.
This commit is contained in:
parent
e5139780ea
commit
44d835947b
4 changed files with 78 additions and 63 deletions
|
@ -25,10 +25,14 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#define L10N // Localization complete.
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <Permission.h>
|
#include <Permission.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
#include <text.h>
|
||||||
|
#include <i18n.h>
|
||||||
#include <CmdAppend.h>
|
#include <CmdAppend.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
@ -37,8 +41,8 @@ extern Context context;
|
||||||
CmdAppend::CmdAppend ()
|
CmdAppend::CmdAppend ()
|
||||||
{
|
{
|
||||||
_keyword = "append";
|
_keyword = "append";
|
||||||
_usage = "task append <IDs> [tags] [attrs] desc...";
|
_usage = "task <filter> append <modifications>";
|
||||||
_description = "Append more description to an existing task.";
|
_description = STRING_CMD_APPEND_USAGE;
|
||||||
_read_only = false;
|
_read_only = false;
|
||||||
_displays_id = false;
|
_displays_id = false;
|
||||||
}
|
}
|
||||||
|
@ -46,39 +50,41 @@ CmdAppend::CmdAppend ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdAppend::execute (std::string& output)
|
int CmdAppend::execute (std::string& output)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (!context.task.has ("description"))
|
|
||||||
throw std::string ("Additional text must be provided.");
|
|
||||||
*/
|
|
||||||
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
/*
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
Filter filter;
|
context.tdb.loadPending (tasks);
|
||||||
context.tdb.loadPending (tasks, filter);
|
|
||||||
|
|
||||||
// Filter sequence.
|
// Apply filter.
|
||||||
std::vector <Task> all = tasks;
|
std::vector <Task> filtered;
|
||||||
context.filter.applySequence (tasks, context.sequence);
|
filter (tasks, filtered);
|
||||||
if (tasks.size () == 0)
|
|
||||||
|
if (filtered.size () == 0)
|
||||||
{
|
{
|
||||||
context.footnote ("No tasks specified.");
|
context.footnote (STRING_FEEDBACK_NO_TASKS_SP);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply the command line modifications to the started task.
|
||||||
|
Arguments modifications = context.args.extract_modifications ();
|
||||||
|
if (!modifications.size ())
|
||||||
|
throw std::string (STRING_CMD_XPEND_NEED_TEXT);
|
||||||
|
|
||||||
Permission permission;
|
Permission permission;
|
||||||
if (context.sequence.size () > (size_t) context.config.getInteger ("bulk"))
|
if (filtered.size () > (size_t) context.config.getInteger ("bulk"))
|
||||||
permission.bigSequence ();
|
permission.bigSequence ();
|
||||||
|
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++task)
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
{
|
{
|
||||||
|
modify_task_description_append (*task, modifications);
|
||||||
|
apply_defaults (*task);
|
||||||
|
|
||||||
std::vector <Task>::iterator other;
|
std::vector <Task>::iterator other;
|
||||||
for (other = all.begin (); other != all.end (); ++other)
|
for (other = tasks.begin (); other != tasks.end (); ++other)
|
||||||
{
|
{
|
||||||
if (other->id == task->id || // Self
|
if (other->id == task->id || // Self
|
||||||
(task->has ("parent") &&
|
(task->has ("parent") &&
|
||||||
|
@ -91,10 +97,9 @@ int CmdAppend::execute (std::string& output)
|
||||||
int changes = 0;
|
int changes = 0;
|
||||||
|
|
||||||
// Apply other deltas.
|
// Apply other deltas.
|
||||||
changes += deltaAppend (*other);
|
modify_task_description_append (*other, modifications);
|
||||||
changes += deltaTags (*other);
|
apply_defaults (*other);
|
||||||
changes += deltaAttributes (*other);
|
++changes;
|
||||||
changes += deltaSubstitutions (*other);
|
|
||||||
|
|
||||||
if (taskDiff (before, *other))
|
if (taskDiff (before, *other))
|
||||||
{
|
{
|
||||||
|
@ -106,11 +111,8 @@ int CmdAppend::execute (std::string& output)
|
||||||
context.tdb.update (*other);
|
context.tdb.update (*other);
|
||||||
|
|
||||||
if (context.config.getBoolean ("echo.command"))
|
if (context.config.getBoolean ("echo.command"))
|
||||||
out << "Appended '"
|
out << format (STRING_CMD_APPEND_DONE, other->id)
|
||||||
<< context.task.get ("description")
|
<< "\n";
|
||||||
<< "' to task "
|
|
||||||
<< other->id
|
|
||||||
<< ".\n";
|
|
||||||
|
|
||||||
if (before.get ("project") != other->get ("project"))
|
if (before.get ("project") != other->get ("project"))
|
||||||
context.footnote (onProjectChange (before, *other));
|
context.footnote (onProjectChange (before, *other));
|
||||||
|
@ -126,10 +128,13 @@ int CmdAppend::execute (std::string& output)
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
if (context.config.getBoolean ("echo.command"))
|
if (context.config.getBoolean ("echo.command"))
|
||||||
out << "Appended " << count << " task" << (count == 1 ? ".\n" : "s.\n");
|
out << format ((count == 1
|
||||||
|
? STRING_CMD_APPEND_SUMMARY
|
||||||
|
: STRING_CMD_APPEND_SUMMARY_N),
|
||||||
|
count)
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,10 +72,6 @@ int CmdDelete::execute (std::string& output)
|
||||||
// Apply the command line modifications to the new task.
|
// Apply the command line modifications to the new task.
|
||||||
Arguments modifications = context.args.extract_modifications ();
|
Arguments modifications = context.args.extract_modifications ();
|
||||||
|
|
||||||
// Determine the end date.
|
|
||||||
char endTime[16];
|
|
||||||
sprintf (endTime, "%u", (unsigned int) time (NULL));
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,10 +25,14 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#define L10N // Localization complete.
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <Permission.h>
|
#include <Permission.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
#include <text.h>
|
||||||
|
#include <i18n.h>
|
||||||
#include <CmdPrepend.h>
|
#include <CmdPrepend.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
@ -37,8 +41,8 @@ extern Context context;
|
||||||
CmdPrepend::CmdPrepend ()
|
CmdPrepend::CmdPrepend ()
|
||||||
{
|
{
|
||||||
_keyword = "prepend";
|
_keyword = "prepend";
|
||||||
_usage = "task prepend <IDs> [tags] [attrs] desc...";
|
_usage = "task <filter> prepend <modifications>";
|
||||||
_description = "Prepends more description to an existing task.";
|
_description = STRING_CMD_PREPEND_USAGE;
|
||||||
_read_only = false;
|
_read_only = false;
|
||||||
_displays_id = false;
|
_displays_id = false;
|
||||||
}
|
}
|
||||||
|
@ -46,39 +50,41 @@ CmdPrepend::CmdPrepend ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdPrepend::execute (std::string& output)
|
int CmdPrepend::execute (std::string& output)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (!context.task.has ("description"))
|
|
||||||
throw std::string ("Additional text must be provided.");
|
|
||||||
*/
|
|
||||||
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
/*
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
Filter filter;
|
context.tdb.loadPending (tasks);
|
||||||
context.tdb.loadPending (tasks, filter);
|
|
||||||
|
|
||||||
// Filter sequence.
|
// Apply filter.
|
||||||
std::vector <Task> all = tasks;
|
std::vector <Task> filtered;
|
||||||
context.filter.applySequence (tasks, context.sequence);
|
filter (tasks, filtered);
|
||||||
if (tasks.size () == 0)
|
|
||||||
|
if (filtered.size () == 0)
|
||||||
{
|
{
|
||||||
context.footnote ("No tasks specified.");
|
context.footnote (STRING_FEEDBACK_NO_TASKS_SP);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply the command line modifications to the started task.
|
||||||
|
Arguments modifications = context.args.extract_modifications ();
|
||||||
|
if (!modifications.size ())
|
||||||
|
throw std::string (STRING_CMD_XPEND_NEED_TEXT);
|
||||||
|
|
||||||
Permission permission;
|
Permission permission;
|
||||||
if (context.sequence.size () > (size_t) context.config.getInteger ("bulk"))
|
if (filtered.size () > (size_t) context.config.getInteger ("bulk"))
|
||||||
permission.bigSequence ();
|
permission.bigSequence ();
|
||||||
|
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++task)
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
{
|
{
|
||||||
|
modify_task_description_prepend (*task, modifications);
|
||||||
|
apply_defaults (*task);
|
||||||
|
|
||||||
std::vector <Task>::iterator other;
|
std::vector <Task>::iterator other;
|
||||||
for (other = all.begin (); other != all.end (); ++other)
|
for (other = tasks.begin (); other != tasks.end (); ++other)
|
||||||
{
|
{
|
||||||
if (other->id == task->id || // Self
|
if (other->id == task->id || // Self
|
||||||
(task->has ("parent") &&
|
(task->has ("parent") &&
|
||||||
|
@ -91,26 +97,22 @@ int CmdPrepend::execute (std::string& output)
|
||||||
int changes = 0;
|
int changes = 0;
|
||||||
|
|
||||||
// Apply other deltas.
|
// Apply other deltas.
|
||||||
changes += deltaPrepend (*other);
|
modify_task_description_prepend (*other, modifications);
|
||||||
changes += deltaTags (*other);
|
apply_defaults (*other);
|
||||||
changes += deltaAttributes (*other);
|
++changes;
|
||||||
changes += deltaSubstitutions (*other);
|
|
||||||
|
|
||||||
if (taskDiff (before, *other))
|
if (taskDiff (before, *other))
|
||||||
{
|
{
|
||||||
// Only allow valid tasks.
|
// Only allow valid tasks.
|
||||||
other->validate ();
|
other->validate ();
|
||||||
|
|
||||||
if (changes && permission.confirmed (before, taskDifferences (before, *other) + "Are you sure?"))
|
if (changes && permission.confirmed (before, taskDifferences (before, *other) + "Proceed with change?"))
|
||||||
{
|
{
|
||||||
context.tdb.update (*other);
|
context.tdb.update (*other);
|
||||||
|
|
||||||
if (context.config.getBoolean ("echo.command"))
|
if (context.config.getBoolean ("echo.command"))
|
||||||
out << "Prepended '"
|
out << format (STRING_CMD_PREPEND_DONE, other->id)
|
||||||
<< context.task.get ("description")
|
<< "\n";
|
||||||
<< "' to task "
|
|
||||||
<< other->id
|
|
||||||
<< ".\n";
|
|
||||||
|
|
||||||
if (before.get ("project") != other->get ("project"))
|
if (before.get ("project") != other->get ("project"))
|
||||||
context.footnote (onProjectChange (before, *other));
|
context.footnote (onProjectChange (before, *other));
|
||||||
|
@ -126,10 +128,13 @@ int CmdPrepend::execute (std::string& output)
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
if (context.config.getBoolean ("echo.command"))
|
if (context.config.getBoolean ("echo.command"))
|
||||||
out << "Prepended " << count << " task" << (count == 1 ? ".\n" : "s.\n");
|
out << format ((count == 1
|
||||||
|
? STRING_CMD_PREPEND_SUMMARY
|
||||||
|
: STRING_CMD_PREPEND_SUMMARY_N),
|
||||||
|
count)
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,6 +274,15 @@
|
||||||
#define STRING_CMD_STOP_USAGE "Removes the 'start' time from a task."
|
#define STRING_CMD_STOP_USAGE "Removes the 'start' time from a task."
|
||||||
#define STRING_CMD_STOP_NOT "Task {1} '{2}' not started."
|
#define STRING_CMD_STOP_NOT "Task {1} '{2}' not started."
|
||||||
#define STRING_CMD_STOP_DONE "Stopped {1} '{2}'."
|
#define STRING_CMD_STOP_DONE "Stopped {1} '{2}'."
|
||||||
|
#define STRING_CMD_APPEND_USAGE "Appends text to an existing task description."
|
||||||
|
#define STRING_CMD_APPEND_DONE "Appended to task {1}."
|
||||||
|
#define STRING_CMD_APPEND_SUMMARY "Appended {1} task."
|
||||||
|
#define STRING_CMD_APPEND_SUMMARY_N "Appended {1} tasks."
|
||||||
|
#define STRING_CMD_PREPEND_USAGE "Prepends text to an existing task description."
|
||||||
|
#define STRING_CMD_PREPEND_DONE "Prepended to task {1}."
|
||||||
|
#define STRING_CMD_PREPEND_SUMMARY "Prepended {1} task."
|
||||||
|
#define STRING_CMD_PREPEND_SUMMARY_N "Prepended {1} tasks."
|
||||||
|
#define STRING_CMD_XPEND_NEED_TEXT "Additional text must be provided."
|
||||||
|
|
||||||
// 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."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue