Merge branch 'translation-lookup-fixes' of https://github.com/vslavik/wxWidgets
Restore correct translation language lookup taking into account message IDs language correctly when it is present in the preferred UI languages but is not the first language in them and other similar corner cases. Also add unit tests verifying that this code logic, already changed many times in the past, does behave correctly now. See #24297.
This commit is contained in:
commit
01ffca369c
13 changed files with 235 additions and 83 deletions
|
|
@ -85,6 +85,11 @@ public:
|
|||
translations offered to the user. To do this, pass the app's main
|
||||
catalog as @a domain.
|
||||
|
||||
@note
|
||||
The returned list does not include messages ID language, i.e. the
|
||||
language (typically English) included in the source code. In the use
|
||||
case described above, that language needs to be added manually.
|
||||
|
||||
@see GetBestTranslation()
|
||||
*/
|
||||
wxArrayString GetAvailableTranslations(const wxString& domain) const;
|
||||
|
|
@ -97,6 +102,12 @@ public:
|
|||
it simply returns the language set with SetLanguage() if it's available
|
||||
or empty string otherwise.
|
||||
|
||||
@warning
|
||||
This function does not consider messages ID language (typically
|
||||
English) and can return inappropriate language if it is anywhere in
|
||||
user's preferred languages list. Use GetBestTranslation() instead
|
||||
unless you have very specific needs.
|
||||
|
||||
@since 3.3.0
|
||||
*/
|
||||
wxString GetBestAvailableTranslation(const wxString& domain);
|
||||
|
|
@ -158,6 +169,16 @@ public:
|
|||
All loaded catalogs will be used for message lookup by GetString() for
|
||||
the current locale.
|
||||
|
||||
@param domain
|
||||
The catalog domain to add.
|
||||
|
||||
@param msgIdLanguage
|
||||
Specifies the language of "msgid" strings in source code
|
||||
(i.e. arguments to GetString(), wxGetTranslation() and the _() macro).
|
||||
It is used if AddCatalog() cannot find any catalog for current language:
|
||||
if the language is same as source code language, then strings from source
|
||||
code are used instead.
|
||||
|
||||
@return
|
||||
@true if catalog was successfully loaded, @false otherwise, usually
|
||||
because it wasn't found. Note that unlike AddCatalog() this
|
||||
|
|
@ -167,9 +188,10 @@ public:
|
|||
selected or system-default languages, but is not necessarily an
|
||||
error if no translations are needed in the first place.
|
||||
|
||||
@since 3.3.0
|
||||
@since 3.2.5
|
||||
*/
|
||||
bool AddAvailableCatalog(const wxString& domain);
|
||||
bool AddAvailableCatalog(const wxString& domain,
|
||||
wxLanguage msgIdLanguage = wxLANGUAGE_ENGLISH_US);
|
||||
|
||||
/**
|
||||
Add a catalog for use with the current locale or fall back to the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue