X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e81b607b4322af54190484aa7ee34112337a344e..26ee65c723cf55822c540506f064ec11d9b26858:/wxPython/src/_intl.i?ds=sidebyside diff --git a/wxPython/src/_intl.i b/wxPython/src/_intl.i index 4b992086ee..c8dff0c6db 100644 --- a/wxPython/src/_intl.i +++ b/wxPython/src/_intl.i @@ -22,14 +22,6 @@ //--------------------------------------------------------------------------- %newgroup -enum wxLayoutDirection -{ - wxLayout_Default, - wxLayout_LeftToRight, - wxLayout_RightToLeft -}; - - enum wxLanguage { // user's default/preffered language as got from OS: @@ -337,12 +329,12 @@ public: ~wxLocale(); %extend { - bool Init1(const wxString& szName, - const wxString& szShort = wxPyEmptyString, - const wxString& szLocale = wxPyEmptyString, + bool Init1(const wxString& name, + const wxString& shortName = wxPyEmptyString, + const wxString& locale = wxPyEmptyString, bool bLoadDefault = true, bool bConvertEncoding = false) { - bool rc = self->Init(szName, szShort, szLocale, bLoadDefault, bConvertEncoding); + bool rc = self->Init(name, shortName, locale, bLoadDefault, bConvertEncoding); // Python before 2.4 needs to have LC_NUMERIC set to "C" in order // for the floating point conversions and such to work right. %#if PY_VERSION_HEX < 0x02040000 @@ -424,10 +416,13 @@ public: // The loaded catalog will be used for message lookup by GetString(). // // Returns 'True' if it was successfully loaded - bool AddCatalog(const wxString& szDomain); + bool AddCatalog(const wxString& domain); + // check if the given locale is provided by OS and C run time + static bool IsAvailable(int lang); + // check if the given catalog is loaded - bool IsLoaded(const wxString& szDomain) const; + bool IsLoaded(const wxString& domain) const; // Retrieve the language info struct for the given language // @@ -460,12 +455,19 @@ public: // // domains are searched in the last to first order, i.e. catalogs // added later override those added before. - wxString GetString(const wxString& szOrigString, - const wxString& szDomain = wxPyEmptyString) const; + wxString GetString(const wxString& origString, + const wxString& domain = wxPyEmptyString) const; // Returns the current short name for the locale const wxString& GetName() const; + + %property(CanonicalName, GetCanonicalName, doc="See `GetCanonicalName`"); + %property(Language, GetLanguage, doc="See `GetLanguage`"); + %property(Locale, GetLocale, doc="See `GetLocale`"); + %property(Name, GetName, doc="See `GetName`"); + %property(String, GetString, doc="See `GetString`"); + %property(SysName, GetSysName, doc="See `GetSysName`"); }; //--------------------------------------------------------------------------- @@ -476,28 +478,31 @@ class wxPyLocale : public wxLocale public: wxPyLocale(); - wxPyLocale(const wxChar *szName, // name (for messages) - const wxChar *szShort = (const wxChar *) NULL, // dir prefix (for msg files) - const wxChar *szLocale = (const wxChar *) NULL, // locale (for setlocale) - bool bLoadDefault = true, // preload wxstd.mo? - bool bConvertEncoding = false); // convert Win<->Unix if necessary? + wxPyLocale(const wxString& name, // name (for messages) + const wxString& shortName = wxPyEmptyString, // dir prefix (for msg files) + const wxString& locale = wxPyEmptyString, // locale (for setlocale) + bool bLoadDefault = true, // preload wxstd.mo? + bool bConvertEncoding = false); // convert Win<->Unix if necessary? wxPyLocale(int language, // wxLanguage id or custom language - int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING); + int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING); ~wxPyLocale(); - virtual const wxChar *GetString(const wxChar *szOrigString, - const wxChar *szDomain = NULL) const; - virtual const wxChar *GetString(const wxChar *szOrigString, - const wxChar *szOrigString2, size_t n, - const wxChar *szDomain = NULL) const; - - virtual wxChar *GetSingularString(const wxChar *szOrigString, - const wxChar *szDomain = NULL) const; - virtual wxChar *GetPluralString(const wxChar *szOrigString, - const wxChar *szOrigString2, size_t n, - const wxChar *szDomain = NULL) const; + virtual const wxString& GetString(const wxString& origString, + const wxString& domain = wxPyEmptyString) const; + virtual const wxString& GetString(const wxString& origString, + const wxString& origString2, + size_t n, + const wxString& domain = wxPyEmptyString) const; + + virtual const wxString& GetSingularString(const wxString& origString, + const wxString& domain = wxPyEmptyString) const; + virtual const wxString& GetPluralString(const wxString& origString, + const wxString& origString2, + size_t n, + const wxString& domain = wxPyEmptyString) const; + PYPRIVATE; private: @@ -508,12 +513,12 @@ wxPyLocale::wxPyLocale() : wxLocale() { } -wxPyLocale::wxPyLocale(const wxChar *szName, // name (for messages) - const wxChar *szShort, // dir prefix (for msg files) - const wxChar *szLocale, // locale (for setlocale) - bool bLoadDefault, // preload wxstd.mo? - bool bConvertEncoding) // convert Win<->Unix if necessary? - : wxLocale(szName, szShort, szLocale, bLoadDefault, bConvertEncoding) +wxPyLocale::wxPyLocale(const wxString& name, // name (for messages) + const wxString& shortName, // dir prefix (for msg files) + const wxString& locale, // locale (for setlocale) + bool bLoadDefault, // preload wxstd.mo? + bool bConvertEncoding) // convert Win<->Unix if necessary? + : wxLocale(name, shortName, locale, bLoadDefault, bConvertEncoding) { } @@ -526,31 +531,29 @@ wxPyLocale::~wxPyLocale() { } -const wxChar *wxPyLocale::GetString(const wxChar *szOrigString, - const wxChar *szDomain) const +const wxString& wxPyLocale::GetString(const wxString& origString, + const wxString& domain) const { - wxChar *str = GetSingularString(szOrigString, szDomain); - return (str != NULL) ? str : wxLocale::GetString(szOrigString, szDomain); + return GetSingularString(origString, domain); } -const wxChar *wxPyLocale::GetString(const wxChar *szOrigString, - const wxChar *szOrigString2, size_t n, - const wxChar *szDomain) const +const wxString& wxPyLocale::GetString(const wxString& origString, + const wxString& origString2, + size_t n, + const wxString& domain) const { - wxChar *str = GetPluralString(szOrigString, szOrigString2, n, szDomain); - return (str != NULL) ? str : wxLocale::GetString(szOrigString, szOrigString2, n, szDomain); + return GetPluralString(origString, origString2, n, domain); } -wxChar *wxPyLocale::GetSingularString(const wxChar *szOrigString, - const wxChar *szDomain) const +const wxString& wxPyLocale::GetSingularString(const wxString& origString, + const wxString& domain) const { bool found; - static wxString str; - str = _T("error in translation"); // when the first if condition is true but the second if condition is not we do not want to return the previously queried string. + wxString str( _T("error in translation")); wxPyBlock_t blocked = wxPyBeginBlockThreads(); - if((found=wxPyCBH_findCallback(m_myInst, "GetSingularString"))) { - PyObject* param1 = wx2PyString(szOrigString); - PyObject* param2 = wx2PyString(szDomain); + if ((found=wxPyCBH_findCallback(m_myInst, "GetSingularString"))) { + PyObject* param1 = wx2PyString(origString); + PyObject* param2 = wx2PyString(domain); PyObject* ret = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OO)", param1, param2)); Py_DECREF(param1); Py_DECREF(param2); @@ -560,22 +563,24 @@ wxChar *wxPyLocale::GetSingularString(const wxChar *szOrigString, } } wxPyEndBlockThreads(blocked); - return (found ? (wxChar*)str.c_str() : NULL); + return (found ? str : wxLocale::GetString(origString, domain)); } -wxChar *wxPyLocale::GetPluralString(const wxChar *szOrigString, - const wxChar *szOrigString2, size_t n, - const wxChar *szDomain) const +const wxString& wxPyLocale::GetPluralString(const wxString& origString, + const wxString& origString2, size_t n, + const wxString& domain) const { bool found; - static wxString str; - str = _T("error in translation"); // when the first if condition is true but the second if condition is not we do not want to return the previously queried string. + wxString str( _T("error in translation")); wxPyBlock_t blocked = wxPyBeginBlockThreads(); - if((found=wxPyCBH_findCallback(m_myInst, "GetPluralString"))) { - PyObject* param1 = wx2PyString(szOrigString); - PyObject* param2 = wx2PyString(szOrigString2); - PyObject* param4 = wx2PyString(szDomain); - PyObject* ret = wxPyCBH_callCallbackObj(m_myInst, Py_BuildValue("(OOiO)", param1, param2, (int)n, param4)); + if ((found=wxPyCBH_findCallback(m_myInst, "GetPluralString"))) { + PyObject* param1 = wx2PyString(origString); + PyObject* param2 = wx2PyString(origString2); + PyObject* param4 = wx2PyString(domain); + PyObject* ret = wxPyCBH_callCallbackObj(m_myInst, + Py_BuildValue("(OOiO)", + param1, param2, + (int)n, param4)); Py_DECREF(param1); Py_DECREF(param2); Py_DECREF(param4); @@ -585,7 +590,7 @@ wxChar *wxPyLocale::GetPluralString(const wxChar *szOrigString, } } wxPyEndBlockThreads(blocked); - return (found ? (wxChar*)str.c_str() : NULL); + return (found ? str : wxLocale::GetString(origString, origString2, n, domain) ); } %} @@ -593,7 +598,7 @@ wxChar *wxPyLocale::GetPluralString(const wxChar *szOrigString, class wxPyLocale : public wxLocale { public: - %pythonAppend wxPyLocale "self._setCallbackInfo(self, PyLocale)" + %pythonAppend wxPyLocale setCallbackInfo(PyLocale) // ctor & dtor // ----------- @@ -617,11 +622,11 @@ public: void _setCallbackInfo(PyObject* self, PyObject* _class); - virtual const wxChar *GetSingularString(const wxChar *szOrigString, - const wxChar *szDomain = NULL) const; - virtual const wxChar *GetPluralString(const wxChar *szOrigString, - const wxChar *szOrigString2, size_t n, - const wxChar *szDomain = NULL) const; + virtual const wxString& GetSingularString(const wxString& origString, + const wxString& domain = wxPyEmptyString) const; + virtual const wxString& GetPluralString(const wxString& origString, + const wxString& origString2, size_t n, + const wxString& domain = wxPyEmptyString) const; }; //---------------------------------------------------------------------------