diff options
Diffstat (limited to 'shared/i18n.h')
-rw-r--r-- | shared/i18n.h | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/shared/i18n.h b/shared/i18n.h index 03456ede..cac6555c 100644 --- a/shared/i18n.h +++ b/shared/i18n.h @@ -7,8 +7,7 @@ #ifndef I18_N_HEADER_3843489325045 #define I18_N_HEADER_3843489325045 -#include <wx/string.h> -#include <vector> +#include <string> namespace zen { @@ -17,9 +16,9 @@ struct TranslationHandler { virtual ~TranslationHandler() {} - virtual wxString thousandsSeparator() = 0; - virtual wxString translate(const wxString& text) = 0; //simple translation - virtual wxString translate(const wxString& singular, const wxString& plural, int n) = 0; + virtual std::wstring thousandsSeparator() = 0; + virtual std::wstring translate(const std::wstring& text) = 0; //simple translation + virtual std::wstring translate(const std::wstring& singular, const std::wstring& plural, int n) = 0; }; void setTranslator(TranslationHandler* newHandler = NULL); //takes ownership @@ -27,26 +26,28 @@ TranslationHandler* getTranslator(); -inline wxString getThousandsSeparator() { return getTranslator() ? getTranslator()->thousandsSeparator() : wxT(","); }; +inline std::wstring getThousandsSeparator() { return getTranslator() ? getTranslator()->thousandsSeparator() : L","; }; -inline wxString translate(const wxString& text) { return getTranslator() ? getTranslator()->translate(text) : text; } +inline std::wstring translate(const std::wstring& text) { return getTranslator() ? getTranslator()->translate(text) : text; } //translate plural forms: "%x day" "%x days" //returns "%x day" if n == 1; "%x days" else for english language -inline wxString translate(const wxString& singular, const wxString& plural, int n) { return getTranslator() ? getTranslator()->translate(singular, plural, n) : n == 1 ? singular : plural; } +inline std::wstring translate(const std::wstring& singular, const std::wstring& plural, int n) { return getTranslator() ? getTranslator()->translate(singular, plural, n) : n == 1 ? singular : plural; } template <class T> inline -wxString translate(const wxString& singular, const wxString& plural, T n) +std::wstring translate(const std::wstring& singular, const std::wstring& plural, T n) { return translate(singular, plural, static_cast<int>(n % 1000000)); } } +#define CONCAT_HELPER(txt1, txt2) txt1 ## txt2 + #ifndef WXINTL_NO_GETTEXT_MACRO #error WXINTL_NO_GETTEXT_MACRO must be defined to deactivate wxWidgets underscore macro #endif -#define _(s) zen::translate(wxT(s)) -#define _P(s, p, n) zen::translate(wxT(s), wxT(p), n) +#define _(s) zen::translate(CONCAT_HELPER(L, s)) +#define _P(s, p, n) zen::translate(CONCAT_HELPER(L, s), CONCAT_HELPER(L, p), n) #endif //I18_N_HEADER_3843489325045 |