X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b1ac3b56e6b5b7342d69aa3b33744c345edb3d1e..e32c4e60825e58a4f17872d6153c00352c8001d6:/src/common/intl.cpp diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 1176aa6ab2..3b26983d77 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -300,6 +300,15 @@ static wxString GetFullSearchPath(const wxChar *lang) if ( pszLcPath != NULL ) searchPath << GetAllMsgCatalogSubdirs(pszLcPath, lang); +#ifdef __UNIX__ + // add some standard ones and the one in the tree where wxWin was installed: + searchPath + << GetAllMsgCatalogSubdirs(wxString(wxGetInstallPrefix()) + wxT("/share/locale"), lang) + << GetAllMsgCatalogSubdirs(wxT("/usr/share/locale"), lang) + << GetAllMsgCatalogSubdirs(wxT("/usr/lib/locale"), lang) + << GetAllMsgCatalogSubdirs(wxT("/usr/local/share/locale"), lang); +#endif // __UNIX__ + // then take the current directory // FIXME it should be the directory of the executable #ifdef __WXMAC__ @@ -310,15 +319,6 @@ static wxString GetFullSearchPath(const wxChar *lang) #else // !Mac searchPath << GetAllMsgCatalogSubdirs(wxT("."), lang); -#ifdef __UNIX__ - // and finally add some standard ones - searchPath - << GetAllMsgCatalogSubdirs(wxString(wxGetInstallPrefix()) + wxT("/share/locale"), lang) - << GetAllMsgCatalogSubdirs(wxT("/usr/share/locale"), lang) - << GetAllMsgCatalogSubdirs(wxT("/usr/lib/locale"), lang) - << GetAllMsgCatalogSubdirs(wxT("/usr/local/share/locale"), lang); -#endif // __UNIX__ - #endif // platform return searchPath; @@ -641,11 +641,7 @@ bool wxLocale::Init(const wxChar *szName, bool wxLocale::Init(int language, int flags) { - wxLanguageInfo *info = NULL; int lang = language; - - CreateLanguagesDB(); - if (lang == wxLANGUAGE_DEFAULT) { // auto detect the language @@ -658,17 +654,7 @@ bool wxLocale::Init(int language, int flags) return FALSE; } - if (lang != wxLANGUAGE_DEFAULT) - { - for (size_t i = 0; i < ms_languagesDB->GetCount(); i++) - { - if (ms_languagesDB->Item(i).Language == lang) - { - info = &ms_languagesDB->Item(i); - break; - } - } - } + const wxLanguageInfo *info = GetLanguageInfo(lang); // Unknown language: if (info == NULL) @@ -1365,12 +1351,30 @@ wxFontEncoding wxLocale::GetSystemEncoding() return wxFONTENCODING_SYSTEM; } -/*static*/ void wxLocale::AddLanguage(const wxLanguageInfo& info) +/* static */ +void wxLocale::AddLanguage(const wxLanguageInfo& info) { CreateLanguagesDB(); ms_languagesDB->Add(info); } +/* static */ +const wxLanguageInfo *wxLocale::GetLanguageInfo(int lang) +{ + CreateLanguagesDB(); + + size_t count = ms_languagesDB->GetCount(); + for ( size_t i = 0; i < count; i++ ) + { + if ( ms_languagesDB->Item(i).Language == lang ) + { + return &ms_languagesDB->Item(i); + } + } + + return NULL; +} + wxString wxLocale::GetSysName() const { return wxSetlocale(LC_ALL, NULL); @@ -2100,7 +2104,7 @@ void wxLocale::InitLanguagesDB() wxLanguageInfo info; wxStringTokenizer tkn; - LNG(wxLANGUAGE_ABKHAZIAN, "ab" , 0 , 0 , "Abkhazian") + LNG(wxLANGUAGE_ABKHAZIAN, "ab" , 0 , 0 , "Abkhazian") LNG(wxLANGUAGE_AFAR, "aa" , 0 , 0 , "Afar") LNG(wxLANGUAGE_AFRIKAANS, "af_ZA", LANG_AFRIKAANS , SUBLANG_DEFAULT , "Afrikaans") LNG(wxLANGUAGE_ALBANIAN, "sq_AL", LANG_ALBANIAN , SUBLANG_DEFAULT , "Albanian")