mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CmdContext: Localize the hardcoded strings
This commit is contained in:
parent
98410cff42
commit
1278226c16
2 changed files with 28 additions and 14 deletions
|
@ -140,15 +140,15 @@ int CmdContext::defineContext (std::vector <std::string>& words, std::stringstre
|
|||
bool success = CmdConfig::setConfigVariable(name, value, confirmation);
|
||||
|
||||
if (success)
|
||||
out << "Context '" << words[1] << "' defined." << "\n";
|
||||
out << format (STRING_CMD_CONTEXT_DEF_SUCC, words[1]) << "\n";
|
||||
else
|
||||
{
|
||||
out << "Context '" << words[1] << "' was not defined." << "\n";
|
||||
out << format (STRING_CMD_CONTEXT_DEF_FAIL, words[1]) << "\n";
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
throw "Both context name and its definition must be provided.";
|
||||
throw STRING_CMD_CONTEXT_DEF_USAG;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -183,12 +183,12 @@ int CmdContext::deleteContext (std::vector <std::string>& words, std::stringstre
|
|||
|
||||
// Output feedback
|
||||
if (rc == 0)
|
||||
out << "Context '" << words[1] << "' undefined." << "\n";
|
||||
out << format (STRING_CMD_CONTEXT_DEL_SUCC, words[1]) << "\n";
|
||||
else
|
||||
out << "Context '" << words[1] << "' was not undefined." << "\n";
|
||||
out << format (STRING_CMD_CONTEXT_DEL_FAIL, words[1]) << "\n";
|
||||
}
|
||||
else
|
||||
throw "Context name needs to be specified.";
|
||||
throw STRING_CMD_CONTEXT_DEL_USAG;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ int CmdContext::listContexts (std::vector <std::string>& words, std::stringstrea
|
|||
}
|
||||
else
|
||||
{
|
||||
out << "No contexts defined." << "\n";
|
||||
out << STRING_CMD_CONTEXT_LIST_EMPT << "\n";
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
|
@ -260,17 +260,17 @@ int CmdContext::setContext (std::vector <std::string>& words, std::stringstream&
|
|||
|
||||
// Check that the specified context is defined
|
||||
if (std::find (contexts.begin (), contexts.end (), value) == contexts.end())
|
||||
throw format ("Context '{1}' not found.", value);
|
||||
throw format (STRING_CMD_CONTEXT_SET_NFOU, value);
|
||||
|
||||
// Set the active context.
|
||||
// Should always succeed, as we do not require confirmation.
|
||||
bool success = CmdConfig::setConfigVariable("context", value, false);
|
||||
|
||||
if (success)
|
||||
out << "Context '" << value << "' applied." << "\n";
|
||||
out << format (STRING_CMD_CONTEXT_SET_SUCC, value) << "\n";
|
||||
else
|
||||
{
|
||||
out << "Context '" << value << "' was not applied." << "\n";
|
||||
out << format (STRING_CMD_CONTEXT_SET_FAIL, value) << "\n";
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
|
@ -290,11 +290,11 @@ int CmdContext::showContext (std::vector <std::string>& words, std::stringstream
|
|||
std::string currentContext = context.config.get ("context");
|
||||
|
||||
if (currentContext == "")
|
||||
out << "No context is currently applied." << "\n";
|
||||
out << STRING_CMD_CONTEXT_SHOW_EMPT << "\n";
|
||||
else
|
||||
{
|
||||
std::string currentFilter = context.config.get ("context." + currentContext);
|
||||
out << format ("Context '{1}' with filter '{2}' is currently applied.", currentContext, currentFilter) << "\n";
|
||||
out << format (STRING_CMD_CONTEXT_SHOW, currentContext, currentFilter) << "\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -316,10 +316,10 @@ int CmdContext::unsetContext (std::vector <std::string>& words, std::stringstrea
|
|||
int status = CmdConfig::unsetConfigVariable("context", false);
|
||||
|
||||
if (status == 0)
|
||||
out << "Context unset." << "\n";
|
||||
out << STRING_CMD_CONTEXT_NON_SUCC << "\n";
|
||||
else
|
||||
{
|
||||
out << "Context not unset." << "\n";
|
||||
out << STRING_CMD_CONTEXT_NON_FAIL << "\n";
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -562,6 +562,20 @@
|
|||
#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"
|
||||
#define STRING_CMD_CONTEXT_USAGE "Set and define contexts (default filters)"
|
||||
#define STRING_CMD_CONTEXT_DEF_SUCC "Context '{1}' defined."
|
||||
#define STRING_CMD_CONTEXT_DEF_FAIL "Context '{1}' not defined."
|
||||
#define STRING_CMD_CONTEXT_DEF_USAG "Both context name and its definition must be provided."
|
||||
#define STRING_CMD_CONTEXT_DEL_SUCC "Context '{1}' deleted."
|
||||
#define STRING_CMD_CONTEXT_DEL_FAIL "Context '{1}' not deleted."
|
||||
#define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified."
|
||||
#define STRING_CMD_CONTEXT_LIST_EMPT "No contexts defined."
|
||||
#define STRING_CMD_CONTEXT_SET_NFOU "Context '{1}' not found."
|
||||
#define STRING_CMD_CONTEXT_SET_SUCC "Context '{1}' applied."
|
||||
#define STRING_CMD_CONTEXT_SET_FAIL "Context '{1}' not applied."
|
||||
#define STRING_CMD_CONTEXT_SHOW_EMPT "No context is currently applied."
|
||||
#define STRING_CMD_CONTEXT_SHOW "Context '{1}' with filter '{2}' is currently applied."
|
||||
#define STRING_CMD_CONTEXT_NON_SUCC "Context unset."
|
||||
#define STRING_CMD_CONTEXT_NON_FAIL "Context not unset."
|
||||
#define STRING_CMD_HCONTEXT_USAGE "Lists all supported contexts, for completion purposes"
|
||||
#define STRING_CMD_CUSTOM_MISMATCH "There are different numbers of columns and labels for report '{1}'."
|
||||
#define STRING_CMD_CUSTOM_SHOWN "{1} shown"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue