mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-02 03:37:19 +02:00
I18N
- Localized the 'config' command.
This commit is contained in:
parent
8e78d9ff48
commit
376c79ef6f
2 changed files with 25 additions and 18 deletions
|
@ -25,9 +25,12 @@
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#define L10N // Localization complete.
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <i18n.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include <CmdConfig.h>
|
#include <CmdConfig.h>
|
||||||
|
@ -39,7 +42,7 @@ CmdConfig::CmdConfig ()
|
||||||
{
|
{
|
||||||
_keyword = "config";
|
_keyword = "config";
|
||||||
_usage = "task config [name [value | '']]";
|
_usage = "task config [name [value | '']]";
|
||||||
_description = "Add, modify and remove settings in the task configuration.";
|
_description = STRING_CMD_CONFIG_USAGE;
|
||||||
_read_only = true;
|
_read_only = true;
|
||||||
_displays_id = false;
|
_displays_id = false;
|
||||||
}
|
}
|
||||||
|
@ -98,12 +101,7 @@ int CmdConfig::execute (std::string& output)
|
||||||
comment > pos))
|
comment > pos))
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
if (confirm (std::string ("Are you sure you want to change the value of '")
|
if (confirm (format (STRING_CMD_CONFIG_CONFIRM, name, context.config.get (name), value)))
|
||||||
+ name
|
|
||||||
+ "' from '"
|
|
||||||
+ context.config.get(name)
|
|
||||||
+ "' to '"
|
|
||||||
+ value + "'?"))
|
|
||||||
{
|
{
|
||||||
if (comment != std::string::npos)
|
if (comment != std::string::npos)
|
||||||
*line = name + "=" + value + " " + line->substr (comment);
|
*line = name + "=" + value + " " + line->substr (comment);
|
||||||
|
@ -117,7 +115,7 @@ int CmdConfig::execute (std::string& output)
|
||||||
|
|
||||||
// Not found, so append instead.
|
// Not found, so append instead.
|
||||||
if (!found &&
|
if (!found &&
|
||||||
confirm (std::string ("Are you sure you want to add '") + name + "' with a value of '" + value + "'?"))
|
confirm (format (STRING_CMD_CONFIG_CONFIRM2, name, value)))
|
||||||
{
|
{
|
||||||
contents.push_back (name + "=" + value);
|
contents.push_back (name + "=" + value);
|
||||||
change = true;
|
change = true;
|
||||||
|
@ -142,7 +140,7 @@ int CmdConfig::execute (std::string& output)
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
// Remove name
|
// Remove name
|
||||||
if (confirm (std::string ("Are you sure you want to remove '") + name + "'?"))
|
if (confirm (format (STRING_CMD_CONFIG_CONFIRM3, name)))
|
||||||
{
|
{
|
||||||
*line = "";
|
*line = "";
|
||||||
change = true;
|
change = true;
|
||||||
|
@ -151,27 +149,27 @@ int CmdConfig::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
throw std::string ("No entry named '") + name + "' found.";
|
throw format (STRING_CMD_CONFIG_NO_ENTRY, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write .taskrc (or equivalent)
|
// Write .taskrc (or equivalent)
|
||||||
if (change)
|
if (change)
|
||||||
{
|
{
|
||||||
File::write (context.config._original_file, contents);
|
File::write (context.config._original_file, contents);
|
||||||
out << "Config file "
|
out << format (STRING_CMD_CONFIG_FILE_MOD,
|
||||||
<< context.config._original_file._data
|
context.config._original_file._data)
|
||||||
<< " modified.\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
out << "No changes made.\n";
|
out << STRING_CMD_CONFIG_NO_CHANGE << "\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw std::string ("Specify the name of a config variable to modify.");
|
throw std::string (STRING_CMD_CONFIG_NO_NAME);
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw std::string ("Specify the name of a config variable to modify.");
|
throw std::string (STRING_CMD_CONFIG_NO_NAME);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -181,8 +179,7 @@ CmdCompletionConfig::CmdCompletionConfig ()
|
||||||
{
|
{
|
||||||
_keyword = "_config";
|
_keyword = "_config";
|
||||||
_usage = "task _config";
|
_usage = "task _config";
|
||||||
_description = "Lists all supported configuration variables, for completion "
|
_description = STRING_CMD_HCONFIG_USAGE;
|
||||||
"purposes.";
|
|
||||||
_read_only = true;
|
_read_only = true;
|
||||||
_displays_id = false;
|
_displays_id = false;
|
||||||
}
|
}
|
||||||
|
|
10
src/en-US.h
10
src/en-US.h
|
@ -369,6 +369,16 @@
|
||||||
#define STRING_CMD_COLOR_RAMP "Gray ramp"
|
#define STRING_CMD_COLOR_RAMP "Gray ramp"
|
||||||
#define STRING_CMD_COLOR_TRY "Try running '{1}'."
|
#define STRING_CMD_COLOR_TRY "Try running '{1}'."
|
||||||
#define STRING_CMD_COLOR_OFF "Color is currently turned off in your .taskrc file. To enable color, remove the line 'color=off', or change the 'off' to 'on'."
|
#define STRING_CMD_COLOR_OFF "Color is currently turned off in your .taskrc file. To enable color, remove the line 'color=off', or change the 'off' to 'on'."
|
||||||
|
#define STRING_CMD_CONFIG_USAGE "Add, modify and remove settings in the task configuration."
|
||||||
|
#define STRING_CMD_CONFIG_CONFIRM "Are you sure you want to change the value of '{1}' from '{2}' to '{3}'?"
|
||||||
|
#define STRING_CMD_CONFIG_CONFIRM2 "Are you sure you want to add '{1}' with a value of '{2}'?"
|
||||||
|
#define STRING_CMD_CONFIG_CONFIRM3 "Are you sure you want to remove '{1}'?"
|
||||||
|
#define STRING_CMD_CONFIG_NO_ENTRY "No entry named '{1}' found."
|
||||||
|
#define STRING_CMD_CONFIG_FILE_MOD "Config file {1} modified."
|
||||||
|
#define STRING_CMD_CONFIG_NO_CHANGE "No changes made."
|
||||||
|
#define STRING_CMD_CONFIG_NO_NAME "Specify the name of a config variable to modify."
|
||||||
|
|
||||||
|
#define STRING_CMD_HCONFIG_USAGE "Lists all supported configuration variables, for completion purposes."
|
||||||
|
|
||||||
// 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