- Localized Hooks.cpp
This commit is contained in:
Paul Beckingham 2011-06-02 22:26:19 -04:00
parent fa36931064
commit e200b2a502
3 changed files with 17 additions and 10 deletions

View file

@ -385,13 +385,8 @@ void Context::createDefaultConfig ()
// Do we need to create a default rc?
if (! rc_file.exists ())
{
if (!confirm ("A configuration file could not be found in " // TODO i18n
+ home_dir
+ "\n\n"
+ "Would you like a sample "
+ rc_file.data
+ " created, so taskwarrior can proceed?"))
throw std::string ("Cannot proceed without rc file.");
if (!confirm (format (STRING_CONTEXT_CREATE_RC, home_dir, rc_file.data)))
throw std::string (STRING_CONTEXT_NEED_RC);
config.createDefaultRC (rc_file, data_dir);
}

View file

@ -30,6 +30,9 @@
#include <Context.h>
#include <Hooks.h>
#include <Timer.h>
#include <i18n.h>
#define L10N // Localization complete.
extern Context context;
@ -143,7 +146,7 @@ void Hooks::initialize ()
(void) n.skip (',');
}
else
throw std::string ("Malformed hook definition '") + *it + "'.";
throw std::string (format (STRING_LUA_BAD_HOOK_DEF, *it));
}
}
}
@ -171,7 +174,7 @@ bool Hooks::trigger (const std::string& event)
return false;
}
else
throw std::string ("Unrecognized hook event '") + event + "'.";
throw std::string (format (STRING_LUA_BAD_EVENT, event));
}
}
#endif
@ -198,7 +201,7 @@ bool Hooks::trigger (const std::string& event, Task& task)
return false;
}
else
throw std::string ("Unrecognized hook event '") + event + "'.";
throw std::string (format (STRING_LUA_BAD_EVENT, event));
}
}
#endif
@ -215,6 +218,7 @@ bool Hooks::validProgramEvent (const std::string& event)
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Hooks::validTaskEvent (const std::string& event)
{
if (std::find (validTaskEvents.begin (), validTaskEvents.end (), event) != validTaskEvents.end ())

View file

@ -108,10 +108,18 @@
#define STRING_CMD_SHOW_CONF_VAR "Config Variable"
#define STRING_CMD_SHOW_CONF_VALUE "Value"
// Context
#define STRING_CONTEXT_CREATE_RC "A configuration file could not be found in {1}\n\nWould you like a sample {2} created, so taskwarrior can proceed?"
#define STRING_CONTEXT_NEED_RC "Cannot proceed without rc file."
// 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}'."
// Lua
#define STRING_LUA_BAD_HOOK_DEF "Malformed hook definition '{1}'."
#define STRING_LUA_BAD_EVENT "Unrecognized hook event '{1}'."
#endif