// Author: Vadim Zeitlin, Vaclav Slavik,
// Michael N. Filippov <michael@idisys.iae.nsk.su>
// Created: 2010-04-23
-// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// (c) 2010 Vaclav Slavik <vslavik@fastmail.fm>
// Licence: wxWindows licence
// forward decls
// ----------------------------------------------------------------------------
+class WXDLLIMPEXP_FWD_BASE wxArrayString;
class WXDLLIMPEXP_FWD_BASE wxTranslationsLoader;
class WXDLLIMPEXP_FWD_BASE wxLocale;
void SetLanguage(wxLanguage lang);
void SetLanguage(const wxString& lang);
+ // get languages available for this app
+ wxArrayString GetAvailableTranslations(const wxString& domain) const;
+
+ // find best translation language for given domain
+ wxString GetBestTranslation(const wxString& domain, wxLanguage msgIdLanguage);
+ wxString GetBestTranslation(const wxString& domain,
+ const wxString& msgIdLanguage = "en");
+
// add standard wxWidgets catalog ("wxstd")
bool AddStdCatalog();
bool IsLoaded(const wxString& domain) const;
// access to translations
- const wxString& GetString(const wxString& origString,
- const wxString& domain = wxEmptyString) const;
- const wxString& GetString(const wxString& origString,
- const wxString& origString2,
- unsigned n,
- const wxString& domain = wxEmptyString) const;
+ const wxString *GetTranslatedString(const wxString& origString,
+ const wxString& domain = wxEmptyString) const;
+ const wxString *GetTranslatedString(const wxString& origString,
+ unsigned n,
+ const wxString& domain = wxEmptyString) const;
wxString GetHeaderValue(const wxString& header,
const wxString& domain = wxEmptyString) const;
private:
// perform loading of the catalog via m_loader
- bool LoadCatalog(const wxString& domain, const wxString& lang);
-
- // find best translation for given domain
- wxString ChooseLanguageForDomain(const wxString& domain,
- const wxString& msgIdLang);
+ bool LoadCatalog(const wxString& domain, const wxString& lang, const wxString& msgIdLang);
// find catalog by name in a linked list, return NULL if !found
wxMsgCatalog *FindCatalog(const wxString& domain) const;
virtual wxMsgCatalog *LoadCatalog(const wxString& domain,
const wxString& lang) = 0;
+
+ virtual wxArrayString GetAvailableTranslations(const wxString& domain) const = 0;
};
virtual wxMsgCatalog *LoadCatalog(const wxString& domain,
const wxString& lang);
+
+ virtual wxArrayString GetAvailableTranslations(const wxString& domain) const;
};
virtual wxMsgCatalog *LoadCatalog(const wxString& domain,
const wxString& lang);
+ virtual wxArrayString GetAvailableTranslations(const wxString& domain) const;
+
protected:
// returns resource type to use for translations
virtual wxString GetResourceType() const { return "MOFILE"; }
// get the translation of the string in the current locale
inline const wxString& wxGetTranslation(const wxString& str,
- const wxString& domain = wxEmptyString)
+ const wxString& domain = wxString())
{
wxTranslations *trans = wxTranslations::Get();
- if ( trans )
- return trans->GetString(str, domain);
+ const wxString *transStr = trans ? trans->GetTranslatedString(str, domain)
+ : NULL;
+ if ( transStr )
+ return *transStr;
else
// NB: this function returns reference to a string, so we have to keep
// a copy of it somewhere
inline const wxString& wxGetTranslation(const wxString& str1,
const wxString& str2,
unsigned n,
- const wxString& domain = wxEmptyString)
+ const wxString& domain = wxString())
{
wxTranslations *trans = wxTranslations::Get();
- if ( trans )
- return trans->GetString(str1, str2, n, domain);
+ const wxString *transStr = trans ? trans->GetTranslatedString(str1, n, domain)
+ : NULL;
+ if ( transStr )
+ return *transStr;
else
// NB: this function returns reference to a string, so we have to keep
// a copy of it somewhere