Removed my previous PanicAlert translation hack. Fixed with a better method suggested by BhaaL. The translation is done by a callback in the MsgHandler routine that is set at program start. Added macros PanicAlertT, SuccessAlertT, PanicYesNoT, and AskYesNoT that are identical to the non T versions except those strings will be added by gettext to the po files to be translated. These can and should be used anywhere in the code for strings that should be translated.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6838 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice
2011-01-13 02:05:58 +00:00
parent be5c732254
commit c6e0ea59b9
78 changed files with 17744 additions and 3451 deletions

View File

@ -25,15 +25,25 @@ bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int S
static MsgAlertHandler msg_handler = DefaultMsgHandler;
static bool AlertEnabled = true;
const char* DefaultStringTranslator(const char* text);
static StringTranslator str_translator = DefaultStringTranslator;
/* Select which of these functions that are used for message boxes. If
wxWidgets is enabled we will use wxMsgAlert() that is defined in main.cpp */
wxWidgets is enabled we will use wxMsgAlert() that is defined in Main.cpp */
void RegisterMsgAlertHandler(MsgAlertHandler handler)
{
msg_handler = handler;
}
// Select translation function. For wxWidgets use wxStringTranslator in Main.cpp
void RegisterStringTranslator(StringTranslator translator)
{
str_translator = translator;
}
// enable/disable the alert handler
void SetEnableAlert(bool enable) {
void SetEnableAlert(bool enable)
{
AlertEnabled = enable;
}
@ -45,9 +55,11 @@ bool MsgAlert(const char* caption, bool yes_no, int Style, const char* format, .
char buffer[2048];
bool ret = true;
const char *tr_format = str_translator(format);
va_list args;
va_start(args, format);
CharArrayFromFormatV(buffer, 2047, format, args);
CharArrayFromFormatV(buffer, 2047, tr_format, args);
va_end(args);
ERROR_LOG(MASTER_LOG, "%s: %s", caption, buffer);
@ -74,3 +86,10 @@ bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int S
return true;
#endif
}
// Default (non) translator
const char* DefaultStringTranslator(const char* text)
{
return text;
}