diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:11:56 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:11:56 +0200 |
commit | 98ecf620f7de377dc8ae9ad7fbd1e3b24477e138 (patch) | |
tree | faadc6d8822c20cd3bc6f50b2a98e6c580585949 /shared/i18n.h | |
parent | 3.16 (diff) | |
download | FreeFileSync-98ecf620f7de377dc8ae9ad7fbd1e3b24477e138.tar.gz FreeFileSync-98ecf620f7de377dc8ae9ad7fbd1e3b24477e138.tar.bz2 FreeFileSync-98ecf620f7de377dc8ae9ad7fbd1e3b24477e138.zip |
3.17
Diffstat (limited to 'shared/i18n.h')
-rw-r--r-- | shared/i18n.h | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/shared/i18n.h b/shared/i18n.h index 0026cdd5..03456ede 100644 --- a/shared/i18n.h +++ b/shared/i18n.h @@ -4,55 +4,49 @@ // * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * // ************************************************************************** // -#ifndef MISC_H_INCLUDED -#define MISC_H_INCLUDED +#ifndef I18_N_HEADER_3843489325045 +#define I18_N_HEADER_3843489325045 #include <wx/string.h> #include <vector> -namespace ffs3 +namespace zen { -struct LocInfoLine +//implement handler to enable program wide localizations +struct TranslationHandler { - int languageID; - wxString languageName; - wxString languageFile; - wxString translatorName; - wxString languageFlag; -}; - -class LocalizationInfo -{ -public: - static const std::vector<LocInfoLine>& get(); - -private: - LocalizationInfo(); - LocalizationInfo(const LocalizationInfo&); - LocalizationInfo& operator=(const LocalizationInfo&); + virtual ~TranslationHandler() {} - std::vector<LocInfoLine> locMapping; + 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; }; +void setTranslator(TranslationHandler* newHandler = NULL); //takes ownership +TranslationHandler* getTranslator(); -//language independent global variables: just use operating system's default setting! -wxString getThousandsSeparator(); -wxString getDecimalPoint(); -void setLanguage(int language); -int getLanguage(); -int retrieveSystemLanguage(); +inline wxString getThousandsSeparator() { return getTranslator() ? getTranslator()->thousandsSeparator() : wxT(","); }; -wxString translate(const wxString& original); //translate into currently selected language +inline wxString translate(const wxString& text) { return getTranslator() ? getTranslator()->translate(text) : text; } -//translate plural forms: "%x day|%x days" +//translate plural forms: "%x day" "%x days" //returns "%x day" if n == 1; "%x days" else for english language -wxString translate(const wxString& original, int n); +inline wxString translate(const wxString& singular, const wxString& 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) +{ + return translate(singular, plural, static_cast<int>(n % 1000000)); } +} + +#ifndef WXINTL_NO_GETTEXT_MACRO +#error WXINTL_NO_GETTEXT_MACRO must be defined to deactivate wxWidgets underscore macro +#endif -//WXINTL_NO_GETTEXT_MACRO must be defined to deactivate wxWidgets underscore macro -#define _(s) ffs3::translate(wxT(s)) -#define _P(s, n) ffs3::translate(wxT(s), n) +#define _(s) zen::translate(wxT(s)) +#define _P(s, p, n) zen::translate(wxT(s), wxT(p), n) -#endif // MISC_H_INCLUDED +#endif //I18_N_HEADER_3843489325045 |