X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2765cbb5aa9f5224ec5b78be6c7137d9cb63fdd3..eccec0f887519b0d1ad69cb0fb2fed0687dc6965:/include/wx/intl.h diff --git a/include/wx/intl.h b/include/wx/intl.h index 615634da7a..cead030884 100644 --- a/include/wx/intl.h +++ b/include/wx/intl.h @@ -10,6 +10,9 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// WARNING: Parts of this file are generated. See misc/languages/README for +// details. + #ifndef _WX_INTL_H_ #define _WX_INTL_H_ @@ -42,20 +45,20 @@ enum wxLayoutDirection // --keyword="_" --keyword="wxPLURAL:1,2" options // to extract the strings from the sources) #ifndef WXINTL_NO_GETTEXT_MACRO - #define _(s) wxGetTranslation(_T(s)) - #define wxPLURAL(sing, plur, n) wxGetTranslation(_T(sing), _T(plur), n) + #define _(s) wxGetTranslation((s)) + #define wxPLURAL(sing, plur, n) wxGetTranslation((sing), (plur), n) #endif // another one which just marks the strings for extraction, but doesn't // perform the translation (use -kwxTRANSLATE with xgettext!) -#define wxTRANSLATE(str) _T(str) +#define wxTRANSLATE(str) str // ---------------------------------------------------------------------------- // forward decls // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_BASE wxLocale; -class WXDLLIMPEXP_BASE wxLanguageInfoArray; +class WXDLLIMPEXP_FWD_BASE wxLocale; +class WXDLLIMPEXP_FWD_BASE wxLanguageInfoArray; class wxMsgCatalog; // ============================================================================ @@ -233,6 +236,7 @@ enum wxLanguage wxLANGUAGE_ROMANIAN, wxLANGUAGE_RUSSIAN, wxLANGUAGE_RUSSIAN_UKRAINE, + wxLANGUAGE_SAMI, wxLANGUAGE_SAMOAN, wxLANGUAGE_SANGHO, wxLANGUAGE_SANSKRIT, @@ -296,6 +300,7 @@ enum wxLanguage wxLANGUAGE_UZBEK, wxLANGUAGE_UZBEK_CYRILLIC, wxLANGUAGE_UZBEK_LATIN, + wxLANGUAGE_VALENCIAN, wxLANGUAGE_VIETNAMESE, wxLANGUAGE_VOLAPUK, wxLANGUAGE_WELSH, @@ -321,14 +326,29 @@ struct WXDLLIMPEXP_BASE wxLanguageInfo { int Language; // wxLanguage id wxString CanonicalName; // Canonical name, e.g. fr_FR -#ifdef __WIN32__ +#ifdef __WXMSW__ wxUint32 WinLang, // Win32 language identifiers WinSublang; -#endif // __WIN32__ +#endif // __WXMSW__ wxString Description; // human-readable name of the language wxLayoutDirection LayoutDirection; + +#ifdef __WXMSW__ + // return the LCID corresponding to this language + wxUint32 GetLCID() const; +#endif // __WXMSW__ + + // return the locale name corresponding to this language usable with + // setlocale() on the current system + wxString GetLocaleName() const; }; +// for Unix systems GetLocaleName() is trivial so implement it inline here, for +// MSW it's implemented in intl.cpp +#ifndef __WXMSW__ +inline wxString wxLanguageInfo::GetLocaleName() const { return CanonicalName; } +#endif // !__WXMSW__ + // ---------------------------------------------------------------------------- // wxLocaleCategory: the category of locale settings // ---------------------------------------------------------------------------- @@ -512,6 +532,11 @@ public: size_t n, const wxString& domain = wxEmptyString) const; + // this is hack to work around a problem with wxGetTranslation() which + // returns const wxString& and not wxString, so when it returns untranslated + // string, it needs to have a copy of it somewhere + static const wxString& GetUntranslatedString(const wxString& str); + // Returns the current short name for the locale const wxString& GetName() const { return m_strShort; } @@ -540,7 +565,7 @@ private: m_strShort; // short name for the locale int m_language; // this locale wxLanguage value - const wxChar *m_pszOldLocale; // previous locale from setlocale() + const char *m_pszOldLocale; // previous locale from setlocale() wxLocale *m_pOldLocale; // previous wxLocale wxMsgCatalog *m_pMsgCat; // pointer to linked list of catalogs @@ -569,7 +594,9 @@ inline const wxString& wxGetTranslation(const wxString& str, if (pLoc) return pLoc->GetString(str, domain); else - return str; + // NB: this function returns reference to a string, so we have to keep + // a copy of it somewhere + return wxLocale::GetUntranslatedString(str); } inline const wxString& wxGetTranslation(const wxString& str1, const wxString& str2, @@ -580,7 +607,11 @@ inline const wxString& wxGetTranslation(const wxString& str1, if (pLoc) return pLoc->GetString(str1, str2, n, domain); else - return n == 1 ? str1 : str2; + // NB: this function returns reference to a string, so we have to keep + // a copy of it somewhere + return n == 1 + ? wxLocale::GetUntranslatedString(str1) + : wxLocale::GetUntranslatedString(str2); } #else // !wxUSE_INTL @@ -589,18 +620,34 @@ inline const wxString& wxGetTranslation(const wxString& str1, #if !defined(WXINTL_NO_GETTEXT_MACRO) #if !defined(_) - #define _(s) (_T(s)) + #define _(s) (s) #endif - #define wxPLURAL(sing, plur, n) ((n) == 1 ? _T(sing) : _T(plur)) + #define wxPLURAL(sing, plur, n) ((n) == 1 ? (sing) : (plur)) #endif -#define wxTRANSLATE(str) _T(str) +#define wxTRANSLATE(str) str -inline const wxString& wxGetTranslation(const wxString& str, - const wxString& WXUNUSED(domain) = wxEmptyString) -{ - return str; -} +// NB: we use a template here in order to avoid using +// wxLocale::GetUntranslatedString() above, which would be required if +// we returned const wxString&; this way, the compiler should be able to +// optimize wxGetTranslation() away + +template +inline TString wxGetTranslation(TString str) + { return str; } + +template +inline TString wxGetTranslation(TString str, TDomain WXUNUSED(domain)) + { return str; } + +template +inline TString wxGetTranslation(TString str1, TString str2, size_t n) + { return n == 1 ? str1 : str2; } + +template +inline TString wxGetTranslation(TString str1, TString str2, size_t n, + TDomain WXUNUSED(domain)) + { return n == 1 ? str1 : str2; } #endif // wxUSE_INTL/!wxUSE_INTL @@ -608,10 +655,10 @@ inline const wxString& wxGetTranslation(const wxString& str, // wxTRANSLATE) too #if !defined(WXINTL_NO_GETTEXT_MACRO) #if !defined(gettext_noop) - #define gettext_noop(str) _T(str) + #define gettext_noop(str) (str) #endif #if !defined(N_) - #define N_(s) _T(s) + #define N_(s) (s) #endif #endif