Mac: Fix Automatic language detection #5337
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a problem on MacOS automatically detecting the language set for system to use in menus, dialogs, etc.
The regional attributes (date, time and numeric [decimal point & thousands separator] formats) were not getting set properly on the Mac when Automatic Detection was used, though they were correct when the country and region were explicitly selected from the list in the Other Options dialog. This was true in 7.22.2. (BOINC has long used automatic detection if the LanguageISO preference tag was an empty string, thus:
LanguageISO=
.) I believe this issue has been present for a very long time, and this may never have worked on the Mac.This occurred because wxLocale for wxLANGUAGE_DEFAULT does not work as expected on the Mac. Mac applications normally provide localization by including a directory for each supported language in the application's bundle. These directories are named xx.lproj, where xx is the 2-letter ISO code for the language; each of these directories contains the translated strings for that language. (MacOS also accepts English.lproj as an alias for en.lproj.)
On Macs, the wxLocale class gets the default ISO language code from MacOS using the Cocoa API
[NSLocale currentLocale]
. As explained here, this API doesn't not necessarily return the actual system language. Rather, it returns the best match to the system language for which there is an xx.lproj directory in the calling application.But BOINC doesn't use Apple's localization scheme; we use wxWidgets' localization, bead on the UNIX gettext translation scheme. Since the only localization in BOINC Manager recognized by MacOS is English,
[NSLocale currentLocale]
always returns English as the default language for BOINC Manager. This results in such odd ISO language codes as en_FR (which would mean English as spoken in France.)In fact, the documentation for wxLocale warns:
and rsays:
The solution is to detect the system language using
wxUILocale::GetSystemLanguage()
and then passing that language instead of wxLANGUAGE_DEFAULT to the wxLocale APIs.