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:
Vadim Zeitlin 2002-09-07 22:53:04 +00:00
parent 27813df1f7
commit 14f8fa9d7f
3 changed files with 37 additions and 17 deletions

View File

@ -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
\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}

View File

@ -450,6 +450,11 @@ public:
// check if the given catalog is loaded
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.
// Notes: 1) wxLanguageInfo contains platform-specific data
// 2) must be called before Init to have effect

View File

@ -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);