added GetHeaderValue() (patch 974427)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28473 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -551,6 +551,14 @@ Domains are searched in the last to first order, i.e. catalogs
|
|||||||
added later override those added before.
|
added later override those added before.
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxLocale::GetHeaderValue}\label{wxlocalegetheadervalue}
|
||||||
|
|
||||||
|
\constfunc{wxString}{GetHeaderValue}{\param{const char }{*szHeader}, \param{const char }{*szDomain = NULL}}
|
||||||
|
|
||||||
|
Returns the header value for header \arg{szHeader}. The search for \arg{szHeader} is case sensitive. If an \arg{szDomain}
|
||||||
|
is passed, this domain is searched. Else all domains will be searched until a header has been found.
|
||||||
|
The return value is the value of the header if found. Else this will be empty.
|
||||||
|
|
||||||
\membersection{wxLocale::GetSysName}\label{wxlocalegetsysname}
|
\membersection{wxLocale::GetSysName}\label{wxlocalegetsysname}
|
||||||
|
|
||||||
\constfunc{wxString}{GetSysName}{\void}
|
\constfunc{wxString}{GetSysName}{\void}
|
||||||
|
@@ -494,16 +494,20 @@ public:
|
|||||||
// domains are searched in the last to first order, i.e. catalogs
|
// domains are searched in the last to first order, i.e. catalogs
|
||||||
// added later override those added before.
|
// added later override those added before.
|
||||||
const wxChar *GetString(const wxChar *szOrigString,
|
const wxChar *GetString(const wxChar *szOrigString,
|
||||||
const wxChar *szDomain = (const wxChar *) NULL) const;
|
const wxChar *szDomain = NULL) const;
|
||||||
// plural form version of the same:
|
// plural form version of the same:
|
||||||
const wxChar *GetString(const wxChar *szOrigString,
|
const wxChar *GetString(const wxChar *szOrigString,
|
||||||
const wxChar *szOrigString2,
|
const wxChar *szOrigString2,
|
||||||
size_t n,
|
size_t n,
|
||||||
const wxChar *szDomain = (const wxChar *) NULL) const;
|
const wxChar *szDomain = NULL) const;
|
||||||
|
|
||||||
// Returns the current short name for the locale
|
// Returns the current short name for the locale
|
||||||
const wxString& GetName() const { return m_strShort; }
|
const wxString& GetName() const { return m_strShort; }
|
||||||
|
|
||||||
|
// return the contents of .po file header
|
||||||
|
wxString GetHeaderValue( const wxChar* szHeader,
|
||||||
|
const wxChar* szDomain = NULL ) const;
|
||||||
|
|
||||||
// These two methods are for internal use only. First one creates
|
// These two methods are for internal use only. First one creates
|
||||||
// ms_languagesDB if it doesn't already exist, second one destroys
|
// ms_languagesDB if it doesn't already exist, second one destroys
|
||||||
// it.
|
// it.
|
||||||
|
@@ -2502,6 +2502,58 @@ const wxChar *wxLocale::GetString(const wxChar *szOrigString,
|
|||||||
return pszTrans;
|
return pszTrans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString wxLocale::GetHeaderValue( const wxChar* szHeader,
|
||||||
|
const wxChar* szDomain ) const
|
||||||
|
{
|
||||||
|
if ( wxIsEmpty(Header) )
|
||||||
|
return wxEmptyString;
|
||||||
|
|
||||||
|
wxChar const * pszTrans = NULL;
|
||||||
|
wxMsgCatalog *pMsgCat;
|
||||||
|
|
||||||
|
if ( szDomain != NULL )
|
||||||
|
{
|
||||||
|
pMsgCat = FindCatalog(szDomain);
|
||||||
|
|
||||||
|
// does the catalog exist?
|
||||||
|
if ( pMsgCat == NULL )
|
||||||
|
return wxEmptyString;
|
||||||
|
|
||||||
|
pszTrans = pMsgCat->GetString(wxT(""), (size_t)-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// search in all domains
|
||||||
|
for ( pMsgCat = m_pMsgCat; pMsgCat != NULL; pMsgCat = pMsgCat->m_pNext )
|
||||||
|
{
|
||||||
|
pszTrans = pMsgCat->GetString(wxT(""), (size_t)-1);
|
||||||
|
if ( pszTrans != NULL ) // take the first found
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( wxIsEmpty(pszTrans) )
|
||||||
|
return wxEmptyString;
|
||||||
|
|
||||||
|
wxChar const * pszFound = wxStrstr(pszTrans, Header);
|
||||||
|
if ( pszFound == NULL )
|
||||||
|
return wxEmptyString;
|
||||||
|
|
||||||
|
pszFound += wxStrlen(Header) + 2 /* ': ' */;
|
||||||
|
|
||||||
|
// Every header is separated by \n
|
||||||
|
|
||||||
|
wxChar const * pszEndLine = wxStrchr(pszFound, wxT('\n'));
|
||||||
|
if ( pszEndLine == NULL ) pszEndLine = pszFound + wxStrlen(pszFound);
|
||||||
|
|
||||||
|
|
||||||
|
// wxString( wxChar*, length);
|
||||||
|
wxString retVal( pszFound, pszEndLine - pszFound );
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// find catalog by name in a linked list, return NULL if !found
|
// find catalog by name in a linked list, return NULL if !found
|
||||||
wxMsgCatalog *wxLocale::FindCatalog(const wxChar *szDomain) const
|
wxMsgCatalog *wxLocale::FindCatalog(const wxChar *szDomain) const
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user