diff --git a/serialize.h b/serialize.h index f3b99978df..aaf3f99051 100644 --- a/serialize.h +++ b/serialize.h @@ -19,7 +19,7 @@ class CScript; class CDataStream; class CAutoFile; -static const int VERSION = 202; +static const int VERSION = 203; static const char* pszSubVer = ".0"; diff --git a/util.cpp b/util.cpp index 266c1dd7df..f4ce556643 100644 --- a/util.cpp +++ b/util.cpp @@ -431,6 +431,35 @@ void ParseParameters(int argc, char* argv[]) } +const char* wxGetTranslation(const char* pszEnglish) +{ + // Wrapper of wxGetTranslation returning the same const char* type as was passed in + static CCriticalSection cs; + CRITICAL_BLOCK(cs) + { + // Look in cache + static map mapCache; + map::iterator mi = mapCache.find(pszEnglish); + if (mi != mapCache.end()) + return (*mi).second; + + // wxWidgets translation + const char* pszTranslated = wxGetTranslation(wxString(pszEnglish, wxConvUTF8)).utf8_str(); + if (strcmp(pszEnglish, pszTranslated) == 0) + return pszEnglish; + + // Add to cache, memory doesn't need to be freed + char* pszCached = new char[strlen(pszTranslated)+1]; + strcpy(pszCached, pszTranslated); + mapCache[pszEnglish] = pszCached; + return pszCached; + } +} + + + + + diff --git a/util.h b/util.h index 188a9ece14..8aed902f3f 100644 --- a/util.h +++ b/util.h @@ -136,6 +136,7 @@ bool ParseMoney(const char* pszIn, int64& nRet); vector ParseHex(const char* psz); vector ParseHex(const std::string& str); void ParseParameters(int argc, char* argv[]); +const char* wxGetTranslation(const char* psz); int GetFilesize(FILE* file); void GetDataDir(char* pszDirRet); string GetDataDir(); @@ -340,11 +341,9 @@ void skipspaces(T& it) ++it; } -inline const char* wxGetTranslation(const char* psz) -{ - // Return translated UTF-8 const char* - return wxGetTranslation(wxString(psz, wxConvUTF8)).utf8_str(); -} + + +