Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac: Fix Automatic language detection #5337

Merged
merged 1 commit into from
Aug 18, 2023
Merged

Conversation

CharlieFenton
Copy link
Contributor

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:

This class is known to have several problems under macOS

and rsays:

it is recommended to use wxUILocale instead of this class for the applications targeting macOS.

The solution is to detect the system language using wxUILocale::GetSystemLanguage() and then passing that language instead of wxLANGUAGE_DEFAULT to the wxLocale APIs.

@CharlieFenton
Copy link
Contributor Author

This PR is ready to merge when CLI checks are complete.

@AenBleidd AenBleidd merged commit 7018ee0 into master Aug 18, 2023
42 of 43 checks passed
@AenBleidd AenBleidd deleted the mac_fix_language_detection branch August 18, 2023 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants