aboutsummaryrefslogtreecommitdiff
path: root/util.cpp
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-02-17 23:55:43 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-02-17 23:55:43 +0000
commitc6ab3cf6d9cf5f5ade3b8fc48590e1bc4794cb43 (patch)
tree58f559dc8b28cf481a6d0128ff64b350603b3f77 /util.cpp
parente4806597650d8a17f1da7a5b5501eb367ea786fc (diff)
safer wxGetTranslation wrapper
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@67 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'util.cpp')
-rw-r--r--util.cpp29
1 files changed, 29 insertions, 0 deletions
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<string, char*> mapCache;
+ map<string, char*>::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;
+ }
+}
+
+
+
+
+