2004-06-03 20:38:14 +02:00
|
|
|
#include "precompiled.h"
|
2003-09-21 23:24:53 +02:00
|
|
|
|
2004-12-05 22:56:09 +01:00
|
|
|
#include "Pyrogenesis.h"
|
2006-06-23 19:41:55 +02:00
|
|
|
#include "ps/i18n.h"
|
2003-11-24 03:18:41 +01:00
|
|
|
|
2003-09-21 23:24:53 +02:00
|
|
|
DEFINE_ERROR(PS_OK, "OK");
|
|
|
|
DEFINE_ERROR(PS_FAIL, "Fail");
|
2006-06-23 19:41:55 +02:00
|
|
|
|
2006-06-25 17:35:28 +02:00
|
|
|
|
|
|
|
static const wchar_t* translate_no_mem = L"(no mem)";
|
|
|
|
|
2006-06-23 19:41:55 +02:00
|
|
|
// overrides ah_translate. registered in GameSetup.cpp
|
|
|
|
const wchar_t* psTranslate(const wchar_t* text)
|
|
|
|
{
|
|
|
|
// make sure i18n system is (already|still) initialized.
|
|
|
|
if(g_CurrentLocale)
|
|
|
|
{
|
|
|
|
// be prepared for this to fail, because translation potentially
|
|
|
|
// involves script code and the JS context might be corrupted.
|
|
|
|
try
|
|
|
|
{
|
|
|
|
CStrW ret = I18n::translate(text);
|
2006-06-25 17:35:28 +02:00
|
|
|
const wchar_t* ret_dup = wcsdup(ret.c_str());
|
|
|
|
return ret_dup? ret_dup : translate_no_mem;
|
2006-06-23 19:41:55 +02:00
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-25 17:35:28 +02:00
|
|
|
// i18n not available: at least try and return the text (unchanged)
|
|
|
|
const wchar_t* ret_dup = wcsdup(text);
|
|
|
|
return ret_dup? ret_dup : translate_no_mem;
|
|
|
|
}
|
|
|
|
|
|
|
|
void psTranslateFree(const wchar_t* text)
|
|
|
|
{
|
|
|
|
if(text != translate_no_mem)
|
|
|
|
free((void*)text);
|
2006-06-23 19:41:55 +02:00
|
|
|
}
|