Rename new wxTranslations method to GetAcceptableTranslations()
This name seems to be more precise than a very generic "all good" one used previously.
This commit is contained in:
@@ -146,9 +146,10 @@ public:
|
|||||||
const wxString& msgIdLanguage = "en");
|
const wxString& msgIdLanguage = "en");
|
||||||
|
|
||||||
// find best and all other suitable translation languages for given domain
|
// find best and all other suitable translation languages for given domain
|
||||||
wxArrayString GetAllGoodTranslations(const wxString& domain, wxLanguage msgIdLanguage);
|
wxArrayString GetAcceptableTranslations(const wxString& domain,
|
||||||
wxArrayString GetAllGoodTranslations(const wxString& domain,
|
wxLanguage msgIdLanguage);
|
||||||
const wxString& msgIdLanguage = "en");
|
wxArrayString GetAcceptableTranslations(const wxString& domain,
|
||||||
|
const wxString& msgIdLanguage = "en");
|
||||||
|
|
||||||
// add standard wxWidgets catalog ("wxstd")
|
// add standard wxWidgets catalog ("wxstd")
|
||||||
bool AddStdCatalog();
|
bool AddStdCatalog();
|
||||||
|
@@ -137,47 +137,32 @@ public:
|
|||||||
const wxString& msgIdLanguage = "en");
|
const wxString& msgIdLanguage = "en");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the best and all other suitable UI languages for the @a domain.
|
Returns the languages of all translations that can be used for the @a
|
||||||
|
domain.
|
||||||
|
|
||||||
This is nearly the same as GetBestTranslation(), but returns the
|
This is a more general version of GetBestTranslation(), which returns
|
||||||
whole list of preferred UI languages for which a translation for the
|
the whole list of preferred UI languages for which a translation for
|
||||||
@a domain was found.
|
the @a domain was found instead of just the first, i.e. the most
|
||||||
|
preferred, element of this list.
|
||||||
|
|
||||||
@param domain
|
@param domain
|
||||||
The catalog domain to look for.
|
The catalog domain to look for.
|
||||||
|
|
||||||
@param msgIdLanguage
|
@param msgIdLanguage
|
||||||
Specifies the language of "msgid" strings in source code
|
Specifies the language of "msgid" strings in source code (i.e.
|
||||||
(i.e. arguments to GetString(), wxGetTranslation() and the _() macro).
|
arguments to GetString(), wxGetTranslation() and the _() macro).
|
||||||
|
|
||||||
@return An array of language codes if any suitable matches were found, empty array
|
@return An array of language codes if any suitable matches were found,
|
||||||
otherwise.
|
empty array otherwise.
|
||||||
|
|
||||||
@since 3.1.2
|
@since 3.1.2
|
||||||
*/
|
*/
|
||||||
wxArrayString GetAllGoodTranslations(const wxString& domain, wxLanguage msgIdLanguage);
|
wxArrayString GetAcceptableTranslations(const wxString& domain,
|
||||||
|
wxLanguage msgIdLanguage);
|
||||||
|
|
||||||
/**
|
/// @overload
|
||||||
Returns the best and all other suitable UI languages for the @a domain.
|
wxArrayString GetAcceptableTranslations(const wxString& domain,
|
||||||
|
const wxString& msgIdLanguage = "en");
|
||||||
This is nearly the same as GetBestTranslation(), but returns the
|
|
||||||
whole list of preferred UI languages for which a translation for the
|
|
||||||
@a domain was found.
|
|
||||||
|
|
||||||
@param domain
|
|
||||||
The catalog domain to look for.
|
|
||||||
|
|
||||||
@param msgIdLanguage
|
|
||||||
Specifies the language of "msgid" strings in source code
|
|
||||||
(i.e. arguments to GetString(), wxGetTranslation() and the _() macro).
|
|
||||||
|
|
||||||
@return An array of language codes if any suitable matches were found, empty array
|
|
||||||
otherwise.
|
|
||||||
|
|
||||||
@since 3.1.2
|
|
||||||
*/
|
|
||||||
wxArrayString GetAllGoodTranslations(const wxString& domain,
|
|
||||||
const wxString& msgIdLanguage = "en");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Add standard wxWidgets catalogs ("wxstd" and possible port-specific
|
Add standard wxWidgets catalogs ("wxstd" and possible port-specific
|
||||||
|
@@ -1555,7 +1555,7 @@ bool wxTranslations::AddCatalog(const wxString& domain,
|
|||||||
wxLanguage msgIdLanguage)
|
wxLanguage msgIdLanguage)
|
||||||
{
|
{
|
||||||
const wxString msgIdLang = wxLocale::GetLanguageCanonicalName(msgIdLanguage);
|
const wxString msgIdLang = wxLocale::GetLanguageCanonicalName(msgIdLanguage);
|
||||||
const wxArrayString domain_langs = GetAllGoodTranslations(domain, msgIdLanguage);
|
const wxArrayString domain_langs = GetAcceptableTranslations(domain, msgIdLanguage);
|
||||||
|
|
||||||
if ( domain_langs.empty() )
|
if ( domain_langs.empty() )
|
||||||
{
|
{
|
||||||
@@ -1675,21 +1675,21 @@ wxString wxTranslations::GetBestTranslation(const wxString& domain,
|
|||||||
wxString wxTranslations::GetBestTranslation(const wxString& domain,
|
wxString wxTranslations::GetBestTranslation(const wxString& domain,
|
||||||
const wxString& msgIdLanguage)
|
const wxString& msgIdLanguage)
|
||||||
{
|
{
|
||||||
const wxArrayString allGoodOnes = GetAllGoodTranslations(domain, msgIdLanguage);
|
const wxArrayString allGoodOnes = GetAcceptableTranslations(domain, msgIdLanguage);
|
||||||
|
|
||||||
wxLogTrace(TRACE_I18N, " => using language '%s'", allGoodOnes[0]);
|
wxLogTrace(TRACE_I18N, " => using language '%s'", allGoodOnes[0]);
|
||||||
return allGoodOnes[0];
|
return allGoodOnes[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
wxArrayString wxTranslations::GetAllGoodTranslations(const wxString& domain,
|
wxArrayString wxTranslations::GetAcceptableTranslations(const wxString& domain,
|
||||||
wxLanguage msgIdLanguage)
|
wxLanguage msgIdLanguage)
|
||||||
{
|
{
|
||||||
const wxString lang = wxLocale::GetLanguageCanonicalName(msgIdLanguage);
|
const wxString lang = wxLocale::GetLanguageCanonicalName(msgIdLanguage);
|
||||||
return GetAllGoodTranslations(domain, lang);
|
return GetAcceptableTranslations(domain, lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxArrayString wxTranslations::GetAllGoodTranslations(const wxString& domain,
|
wxArrayString wxTranslations::GetAcceptableTranslations(const wxString& domain,
|
||||||
const wxString& msgIdLanguage)
|
const wxString& msgIdLanguage)
|
||||||
{
|
{
|
||||||
wxArrayString available(GetAvailableTranslations(domain));
|
wxArrayString available(GetAvailableTranslations(domain));
|
||||||
// it's OK to have duplicates, so just add msgid language
|
// it's OK to have duplicates, so just add msgid language
|
||||||
|
Reference in New Issue
Block a user