Opened 5 years ago

Closed 5 years ago

#15522 closed defect (fixed)

wxLocale::AddCatalog() has changed behavior from 2.8.4 to 2.9.3 (and on)

Reported by: tmsorensen Owned by:
Priority: normal Milestone:
Component: translations Version: 2.9.3
Keywords: wxTranslations wxLocale Cc:
Blocked By: Blocking:
Patch: yes


In wx 2.8.4 the "main" wxLocale::AddCatalog() function will always attempt to load a translation no matter which msgIdLanguage argument it is given (specifically wxLANGUAGE_ENGLISH_US). Only if the loading of a translation file fails is msgIdLanguage compared to m_language and, if they are the same, it is deemed OK to just use the text embedded in the code (and the function returns true)

In wx 2.9.3 and up, this behavior has been changed: wxLocale::AddCatalog() uses wxTranslations::AddCatalog() and this function simply says that if the msgIdLanguage argument is the same as the domain language, the program should always use the text embedded in the code. No attempt is made at loading a translation file.

I believe this is a bug. Our product is localized into nine different languages, one being English. We write the text embedded in the code in English but none of the developers are native English speakers so this text may not always be correct. Therefore we have hired a company to do the translations and this scheme kinda fails when the English .mo file is not loaded :-)

I have provided a patch against trunk for "include/wx/translation.h" and "src/common/translation.cpp" that fixes this problem and implements the behavior intended in wx 2.8.4 (which I believe is the right one, of course :-)

Attachments (1)

wxWidgets-trunk.patch download (2.1 KB) - added by tmsorensen 5 years ago.
patch to translation.h and translation.cpp

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by tmsorensen

patch to translation.h and translation.cpp

comment:1 Changed 5 years ago by vaclavslavik

I believe this is a bug.

It's not. You are arguably misusing gettext in some interesting ways (did you consider updating the source code strings?), but well, I don't think there's any harm in making it possible. The impact of some additional catalog lookups is hopefully going to be minimal, so I applied your patch -- thanks!

comment:2 Changed 5 years ago by VS

  • Resolution set to fixed
  • Status changed from new to closed

(In [74849]) Try loading even English translations if provided.

Doing so has negligible cost and can be useful in some situations (e.g.
when using symbolic msgids despite gettext best practices).

Patch by tmsorensen.

Fixes #15522.

Note: See TracTickets for help on using tickets.