added wxLocale::GetLanguageInfo()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@17060 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -419,6 +419,17 @@ Returns \helpref{wxLanguage}{wxlanguage} constant of current language.
|
|||||||
Note that you can call this function only if you used the form of
|
Note that you can call this function only if you used the form of
|
||||||
\helpref{Init}{wxlocaleinit} that takes wxLanguage argument.
|
\helpref{Init}{wxlocaleinit} that takes wxLanguage argument.
|
||||||
|
|
||||||
|
\membersection{wxLocale::GetLanguageInfo}\label{wxlocalegetlanguageinfo}
|
||||||
|
|
||||||
|
\constfunc{static wxLanguageInfo *}{GetLanguageInfo}{\param{int }{lang}}
|
||||||
|
|
||||||
|
Returns a pointer to wxLanguageInfo structure containing information about the
|
||||||
|
given language or {\tt NULL} if this language is unknown. Note that even if the
|
||||||
|
returned pointer is valid, the caller should {\it not} delete it.
|
||||||
|
|
||||||
|
See \helpref{AddLanguage}{wxlocaleaddlanguage} for the wxLanguageInfo
|
||||||
|
description.
|
||||||
|
|
||||||
|
|
||||||
\membersection{wxLocale::GetLocale}\label{wxlocalegetlocale}
|
\membersection{wxLocale::GetLocale}\label{wxlocalegetlocale}
|
||||||
|
|
||||||
|
@@ -450,6 +450,11 @@ public:
|
|||||||
// check if the given catalog is loaded
|
// check if the given catalog is loaded
|
||||||
bool IsLoaded(const wxChar *szDomain) const;
|
bool IsLoaded(const wxChar *szDomain) const;
|
||||||
|
|
||||||
|
// Retrieve the language info struct for the given language
|
||||||
|
//
|
||||||
|
// Returns NULL if no info found, pointer must *not* be deleted by caller
|
||||||
|
static const wxLanguageInfo *GetLanguageInfo(int lang);
|
||||||
|
|
||||||
// Add custom language to the list of known languages.
|
// Add custom language to the list of known languages.
|
||||||
// Notes: 1) wxLanguageInfo contains platform-specific data
|
// Notes: 1) wxLanguageInfo contains platform-specific data
|
||||||
// 2) must be called before Init to have effect
|
// 2) must be called before Init to have effect
|
||||||
|
@@ -641,11 +641,7 @@ bool wxLocale::Init(const wxChar *szName,
|
|||||||
|
|
||||||
bool wxLocale::Init(int language, int flags)
|
bool wxLocale::Init(int language, int flags)
|
||||||
{
|
{
|
||||||
wxLanguageInfo *info = NULL;
|
|
||||||
int lang = language;
|
int lang = language;
|
||||||
|
|
||||||
CreateLanguagesDB();
|
|
||||||
|
|
||||||
if (lang == wxLANGUAGE_DEFAULT)
|
if (lang == wxLANGUAGE_DEFAULT)
|
||||||
{
|
{
|
||||||
// auto detect the language
|
// auto detect the language
|
||||||
@@ -658,17 +654,7 @@ bool wxLocale::Init(int language, int flags)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lang != wxLANGUAGE_DEFAULT)
|
const wxLanguageInfo *info = GetLanguageInfo(lang);
|
||||||
{
|
|
||||||
for (size_t i = 0; i < ms_languagesDB->GetCount(); i++)
|
|
||||||
{
|
|
||||||
if (ms_languagesDB->Item(i).Language == lang)
|
|
||||||
{
|
|
||||||
info = &ms_languagesDB->Item(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unknown language:
|
// Unknown language:
|
||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
@@ -1365,12 +1351,30 @@ wxFontEncoding wxLocale::GetSystemEncoding()
|
|||||||
return wxFONTENCODING_SYSTEM;
|
return wxFONTENCODING_SYSTEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ void wxLocale::AddLanguage(const wxLanguageInfo& info)
|
/* static */
|
||||||
|
void wxLocale::AddLanguage(const wxLanguageInfo& info)
|
||||||
{
|
{
|
||||||
CreateLanguagesDB();
|
CreateLanguagesDB();
|
||||||
ms_languagesDB->Add(info);
|
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
|
wxString wxLocale::GetSysName() const
|
||||||
{
|
{
|
||||||
return wxSetlocale(LC_ALL, NULL);
|
return wxSetlocale(LC_ALL, NULL);
|
||||||
@@ -2100,7 +2104,7 @@ void wxLocale::InitLanguagesDB()
|
|||||||
wxLanguageInfo info;
|
wxLanguageInfo info;
|
||||||
wxStringTokenizer tkn;
|
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_AFAR, "aa" , 0 , 0 , "Afar")
|
||||||
LNG(wxLANGUAGE_AFRIKAANS, "af_ZA", LANG_AFRIKAANS , SUBLANG_DEFAULT , "Afrikaans")
|
LNG(wxLANGUAGE_AFRIKAANS, "af_ZA", LANG_AFRIKAANS , SUBLANG_DEFAULT , "Afrikaans")
|
||||||
LNG(wxLANGUAGE_ALBANIAN, "sq_AL", LANG_ALBANIAN , SUBLANG_DEFAULT , "Albanian")
|
LNG(wxLANGUAGE_ALBANIAN, "sq_AL", LANG_ALBANIAN , SUBLANG_DEFAULT , "Albanian")
|
||||||
|
Reference in New Issue
Block a user