mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
i18n
- Localized a few strings, for fun.
This commit is contained in:
parent
62203a45f8
commit
02065c3cdc
8 changed files with 50 additions and 232 deletions
|
@ -164,7 +164,7 @@ int Context::run ()
|
|||
|
||||
catch (...)
|
||||
{
|
||||
footnote ("Unknown error.");
|
||||
footnote (STRING_UNKNOWN_ERROR);
|
||||
rc = 3;
|
||||
}
|
||||
|
||||
|
@ -369,6 +369,7 @@ bool Context::verbose (const std::string& token)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO OBSOLETE
|
||||
void Context::shadow ()
|
||||
{
|
||||
// Determine if shadow file is enabled.
|
||||
|
@ -536,7 +537,7 @@ void Context::assumeLocations ()
|
|||
// Set up default locations.
|
||||
struct passwd* pw = getpwuid (getuid ());
|
||||
if (!pw)
|
||||
throw std::string ("Could not read home directory from the passwd file.");
|
||||
throw std::string (STRING_NO_HOME);
|
||||
|
||||
home_dir = pw->pw_dir;
|
||||
rc_file = File (home_dir + "/.taskrc");
|
||||
|
@ -722,7 +723,7 @@ void Context::parse (
|
|||
foundNonSequence = true;
|
||||
|
||||
if (arg->find (',') != std::string::npos)
|
||||
throw std::string ("Tags are not permitted to contain commas.");
|
||||
throw std::string (STRING_TAGS_NO_COMMAS);
|
||||
|
||||
tagAdditions.push_back (arg->substr (1));
|
||||
parseTask.addTag (arg->substr (1));
|
||||
|
@ -740,7 +741,7 @@ void Context::parse (
|
|||
foundNonSequence = true;
|
||||
|
||||
if (arg->find (',') != std::string::npos)
|
||||
throw std::string ("Tags are not permitted to contain commas.");
|
||||
throw std::string (STRING_TAGS_NO_COMMAS);
|
||||
|
||||
tagRemovals.push_back (arg->substr (1));
|
||||
}
|
||||
|
@ -900,7 +901,7 @@ void Context::parse (
|
|||
parse (args, cmd, task, sequence, subst, filter);
|
||||
}
|
||||
else
|
||||
throw std::string ("You must specify a command, or a task ID to modify.");
|
||||
throw std::string (STRING_TRIVIAL_INPUT);
|
||||
}
|
||||
|
||||
// If the command "task 123" is entered, but with no modifier arguments,
|
||||
|
@ -908,7 +909,7 @@ void Context::parse (
|
|||
else if (!foundNonSequence &&
|
||||
(parseTask.id != 0 || parseSequence.size () != 0))
|
||||
{
|
||||
std::cout << "No command - assuming 'info'.\n";
|
||||
std::cout << STRING_ASSUME_INFO << "\n";
|
||||
parseCmd.command = "info";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <sstream>
|
||||
#include <Context.h>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
#include <DOM.h>
|
||||
#include "../cmake.h"
|
||||
|
||||
|
@ -138,7 +139,7 @@ const std::string DOM::get (const std::string& name)
|
|||
#elif defined (LINUX)
|
||||
return "Linux";
|
||||
#else
|
||||
return "<unknown>";
|
||||
return STRING_DOM_UNKNOWN
|
||||
#endif
|
||||
|
||||
else
|
||||
|
|
|
@ -66,7 +66,8 @@ int CmdHelp::execute (const std::string& command_line, std::string& output)
|
|||
// Sort alphabetically by usage.
|
||||
std::sort (all.begin (), all.end ());
|
||||
|
||||
foreach (name, all)
|
||||
std::vector <std::string>::iterator name;
|
||||
for (name = all.begin (); name != all.end (); ++name)
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 1, context.commands[*name]->usage ());
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <text.h>
|
||||
#include <i18n.h>
|
||||
#include <Context.h>
|
||||
#include <Directory.h>
|
||||
#include <ViewText.h>
|
||||
|
@ -40,8 +41,7 @@ CmdShow::CmdShow ()
|
|||
{
|
||||
_keyword = "show";
|
||||
_usage = "task show [all | substring]";
|
||||
_description = "Shows the entire task configuration variables or the ones "
|
||||
"containing substring.";
|
||||
_description = STRING_CMD_SHOW;
|
||||
_read_only = true;
|
||||
_displays_id = false;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ int CmdShow::execute (const std::string& command_line, std::string& output)
|
|||
split (args, context.task.get ("description"), ' ');
|
||||
|
||||
if (args.size () > 1)
|
||||
throw std::string ("You can only specify 'all' or a search string.");
|
||||
throw std::string (STRING_CMD_SHOW_ARGS);
|
||||
|
||||
int width = context.getWidth ();
|
||||
|
||||
|
@ -183,12 +183,13 @@ int CmdShow::execute (const std::string& command_line, std::string& output)
|
|||
|
||||
out << "\n"
|
||||
<< view.render ()
|
||||
<< (view.rows () == 0 ? "No matching configuration variables.\n\n" : "\n");
|
||||
<< (view.rows () == 0 ? STRING_CMD_SHOW_NONE : "")
|
||||
<< (view.rows () == 0 ? "\n\n" : "\n");
|
||||
|
||||
// Display the unrecognized variables.
|
||||
if (unrecognized.size ())
|
||||
{
|
||||
out << "Your .taskrc file contains these unrecognized variables:\n";
|
||||
out << STRING_CMD_SHOW_UNREC << "\n";
|
||||
|
||||
for (i = unrecognized.begin (); i != unrecognized.end (); ++i)
|
||||
out << " " << *i << "\n";
|
||||
|
@ -201,7 +202,7 @@ int CmdShow::execute (const std::string& command_line, std::string& output)
|
|||
|
||||
if (default_values.size ())
|
||||
{
|
||||
out << "Some of your .taskrc variables differ from the default values.";
|
||||
out << STRING_CMD_SHOW_DIFFER;
|
||||
|
||||
if (context.color ())
|
||||
out << " These are highlighted in " << warning.colorize ("color") << " above.";
|
||||
|
@ -244,7 +245,7 @@ int CmdShow::execute (const std::string& command_line, std::string& output)
|
|||
|
||||
if (missing_scripts.size ())
|
||||
{
|
||||
out << "Your .taskrc file contains these missing or unreadable hook scripts:\n";
|
||||
out << STRING_CMD_SHOW_HOOKS << "\n";
|
||||
|
||||
for (i = missing_scripts.begin (); i != missing_scripts.end (); ++i)
|
||||
out << " " << *i << "\n";
|
||||
|
@ -295,7 +296,7 @@ int CmdShow::execute (const std::string& command_line, std::string& output)
|
|||
|
||||
if (all.size () == 0)
|
||||
{
|
||||
out << "Configuration error: .taskrc contains no entries.\n";
|
||||
out << STRING_CMD_SHOW_EMPTY << "\n";
|
||||
rc = 1;
|
||||
}
|
||||
else
|
||||
|
|
28
src/en-US.h
28
src/en-US.h
|
@ -28,11 +28,16 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Strings that should be localized:
|
||||
// - All text output that the user sees or types
|
||||
// - text output that the user sees or types
|
||||
//
|
||||
// Strings that should NOT be localized:
|
||||
// - ./taskrc configuration variable names
|
||||
// - command names
|
||||
// - extension function names
|
||||
// - certain literals associated with parsing
|
||||
// - debug strings
|
||||
// - attribute names
|
||||
// - modifier names
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -41,7 +46,26 @@
|
|||
|
||||
// To localize, clone and rename this file, then change all the defines below.
|
||||
|
||||
#define STRING_UNKNOWN_ERROR "Unknown error."
|
||||
// Errors
|
||||
#define STRING_UNKNOWN_ERROR "Unknown error."
|
||||
#define STRING_NO_HOME "Could not read home directory from the passwd file."
|
||||
#define STRING_TAGS_NO_COMMAS "Tags are not permitted to contain commas."
|
||||
#define STRING_TRIVIAL_INPUT "You must specify a command, or a task ID to modify."
|
||||
#define STRING_ASSUME_INFO "No command - assuming 'info'"
|
||||
|
||||
// 'show' command
|
||||
#define STRING_CMD_SHOW "Shows the entire task configuration variables or the ones containing substring."
|
||||
#define STRING_CMD_SHOW_ARGS "You can only specify 'all' or a search string."
|
||||
#define STRING_CMD_SHOW_NONE "No matching configuration variables."
|
||||
#define STRING_CMD_SHOW_UNREC "Your .taskrc file contains these unrecognized variables:"
|
||||
#define STRING_CMD_SHOW_DIFFER "Some of your .taskrc variables differ from the default values."
|
||||
#define STRING_CMD_SHOW_HOOKS "Your .taskrc file contains these missing or unreadable hook scripts:"
|
||||
#define STRING_CMD_SHOW_EMPTY "Configuration error: .taskrc contains no entries."
|
||||
|
||||
// DOM
|
||||
#define STRING_DOM_UNKNOWN "<unknown>"
|
||||
#define STRING_DOM_UNREC "DOM: Cannot get unrecognized name '{1}'."
|
||||
#define STRING_DOM_CANNOT_SET "DOM: Cannot set '{1}'."
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue