mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
I18N
- Localized more commands.
This commit is contained in:
parent
44d835947b
commit
d33de00eac
3 changed files with 48 additions and 30 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 <CmdAnnotate.h>
|
#include <CmdAnnotate.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
@ -38,7 +42,7 @@ CmdAnnotate::CmdAnnotate ()
|
||||||
{
|
{
|
||||||
_keyword = "annotate";
|
_keyword = "annotate";
|
||||||
_usage = "task annotate ID desc...";
|
_usage = "task annotate ID desc...";
|
||||||
_description = "Adds an annotation to an existing task.";
|
_description = STRING_CMD_ANNO_USAGE;
|
||||||
_read_only = false;
|
_read_only = false;
|
||||||
_displays_id = false;
|
_displays_id = false;
|
||||||
}
|
}
|
||||||
|
@ -47,63 +51,73 @@ CmdAnnotate::CmdAnnotate ()
|
||||||
int CmdAnnotate::execute (std::string& output)
|
int CmdAnnotate::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
int count = 0;
|
||||||
/*
|
|
||||||
if (!context.task.has ("description"))
|
|
||||||
throw std::string ("Cannot apply a blank annotation.");
|
|
||||||
|
|
||||||
if (context.sequence.size () == 0)
|
|
||||||
throw std::string ("ID needed to apply an annotation.");
|
|
||||||
|
|
||||||
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.
|
||||||
context.filter.applySequence (tasks, context.sequence);
|
std::vector <Task> filtered;
|
||||||
if (tasks.size () == 0)
|
filter (tasks, filtered);
|
||||||
|
|
||||||
|
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 completed 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)
|
||||||
{
|
{
|
||||||
Task before (*task);
|
Task before (*task);
|
||||||
task->addAnnotation (context.task.get ("description"));
|
modify_task_annotate (*task, modifications);
|
||||||
|
apply_defaults (*task);
|
||||||
|
|
||||||
if (taskDiff (before, *task))
|
|
||||||
{
|
|
||||||
// Only allow valid tasks.
|
// Only allow valid tasks.
|
||||||
task->validate ();
|
task->validate ();
|
||||||
|
|
||||||
if (permission.confirmed (before, taskDifferences (before, *task) + "Proceed with change?"))
|
if (taskDiff (before, *task))
|
||||||
|
{
|
||||||
|
if (permission.confirmed (before,
|
||||||
|
taskDifferences (before, *task)
|
||||||
|
+ STRING_CMD_DONE_PROCEED))
|
||||||
{
|
{
|
||||||
context.tdb.update (*task);
|
context.tdb.update (*task);
|
||||||
|
++count;
|
||||||
|
|
||||||
if (context.config.getBoolean ("echo.command"))
|
if (context.config.getBoolean ("echo.command"))
|
||||||
out << "Annotated "
|
out << format (STRING_CMD_ANNO_DONE,
|
||||||
<< task->id
|
task->id,
|
||||||
<< " with '"
|
task->get ("description"))
|
||||||
<< context.task.get ("description")
|
<< "\n";
|
||||||
<< "'.\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count)
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
|
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
if (context.config.getBoolean ("echo.command"))
|
||||||
|
out << format ((count == 1
|
||||||
|
? STRING_CMD_ANNO_SUMMARY
|
||||||
|
: STRING_CMD_ANNO_SUMMARY_N),
|
||||||
|
count)
|
||||||
|
<< "\n";
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,7 @@ int CmdDone::execute (std::string& output)
|
||||||
if (permission.confirmed (before, taskDifferences (before, *task) + STRING_CMD_DONE_PROCEED))
|
if (permission.confirmed (before, taskDifferences (before, *task) + STRING_CMD_DONE_PROCEED))
|
||||||
{
|
{
|
||||||
context.tdb.update (*task);
|
context.tdb.update (*task);
|
||||||
|
++count;
|
||||||
|
|
||||||
if (context.config.getBoolean ("echo.command"))
|
if (context.config.getBoolean ("echo.command"))
|
||||||
out << format (STRING_CMD_DONE_COMPLETED, task->id, task->get ("description"))
|
out << format (STRING_CMD_DONE_COMPLETED, task->id, task->get ("description"))
|
||||||
|
@ -111,7 +112,6 @@ int CmdDone::execute (std::string& output)
|
||||||
dependencyChainOnComplete (*task);
|
dependencyChainOnComplete (*task);
|
||||||
context.footnote (onProjectChange (*task, false));
|
context.footnote (onProjectChange (*task, false));
|
||||||
|
|
||||||
++count;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -283,6 +283,10 @@
|
||||||
#define STRING_CMD_PREPEND_SUMMARY "Prepended {1} task."
|
#define STRING_CMD_PREPEND_SUMMARY "Prepended {1} task."
|
||||||
#define STRING_CMD_PREPEND_SUMMARY_N "Prepended {1} tasks."
|
#define STRING_CMD_PREPEND_SUMMARY_N "Prepended {1} tasks."
|
||||||
#define STRING_CMD_XPEND_NEED_TEXT "Additional text must be provided."
|
#define STRING_CMD_XPEND_NEED_TEXT "Additional text must be provided."
|
||||||
|
#define STRING_CMD_ANNO_USAGE "Adds an annotation to an existing task."
|
||||||
|
#define STRING_CMD_ANNO_DONE "Annotated {1} '{2}'"
|
||||||
|
#define STRING_CMD_ANNO_SUMMARY "Prepended {1} task."
|
||||||
|
#define STRING_CMD_ANNO_SUMMARY_N "Prepended {1} tasks."
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
#define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake."
|
#define STRING_CONFIG_OVERNEST "Configuration file nested to more than 10 levels deep - this has to be a mistake."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue