Method GetBestTranslation() uses internally static methods of wxUILocaleImpl which in turn require an initialized language database. Calls to wxUILocaleImpl::CreateLanguagesDB() are added to guarantee this.
https://github.com/wxWidgets/wxWidgets/pull/26050
(1 file)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Thanks, I'll merge this if/when it's confirmed that this fixes #26044, even though I'm not particularly happy with the fact that we need to remember to call this function instead of relying on some way for it to be called automatically — but this will be something to improve in 2026.
Thanks again!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Thanks, I'll merge this if/when it's confirmed that this fixes #26044,
It fixes #26044. As described there the correct result (en) was returned, when wxMessageBox_ was called. And as explained a side effect of calling wxMessageBox` is that the language database is initialized.
even though I'm not particularly happy with the fact that we need to remember to call this function instead of relying on some way for it to be called automatically — but this will be something to improve in 2026.
Yes, being forced to call CreateLanguagesDB() is far from ideal. The change introduced by this PR is a very local modification (affecting only a single source file). Nevertheless, initializing the language database automatically is most likely preferrable.
In file common/intl.cpp there is already a wxLocaleModule class that is used to automatically destroy the language database. Why not use that class to automatically create the language database?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
In file
common/intl.cppthere is already awxLocaleModuleclass that is used to automatically destroy the language database. Why not use that class to automatically create the language database?
The only reason I can see is to postpone initializing it until it's really needed. In principle, it's possible that it is never used, I think?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
In file
common/intl.cppthere is already awxLocaleModuleclass that is used to automatically destroy the language database. Why not use that class to automatically create the language database?The only reason I can see is to postpone initializing it until it's really needed. In principle, it's possible that it is never used, I think?
In principle, you are right. However, if you take into account that even a simple function call like wxMessageBox() already triggers the initialization of the language database (as a side effect of calling GetLayoutDirection() internally), if symbol wxUSE_INTL is defined, it is justifiable to initialize the language database unconditionally.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
However, if you take into account that even a simple function call like
wxMessageBox()already triggers the initialization of the language database (as a side effect of callingGetLayoutDirection()internally), if symbolwxUSE_INTLis defined, it is justifiable to initialize the language database unconditionally.
OTOH the static methods in languageinfo.cpp now take care of initializing the language database. And the static global data structures are not referenced from anywhere else. So, applying this PR efficiently solves the issue.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()