electron: app.getLocale() on MacOS returns wrong value in latest electron versions

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 9.3.4, 10.1.16
  • Operating System:
    • Mac OS 10.13, 10.14, 10.15, 11.0
  • Last Known Working Electron version:
    • 9.3.3, 10.1.15

Expected Behavior

app.getLocale() should return correct locale.zh-CN, e.g.

Actual Behavior

app.getLocale() always returns ‘en-US’.

To Reproduce

const app = require('electron')

app.whenReady().then(()=>{
  console.log(app.getLocale());
});

Screenshots

Additional Information

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 11
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

From my understanding 11.0.0 and the betas of 11 where locale was always working were released before 10.1.6. (11-beta1 was released in August, 11.0.0 on 16 Nov 2020 and 10.1.6 on 18 Nov 2020).

So from my point of view there is no commit on 11 that fixes it, as it was never broken and thus never fixed. Its only broken on the 10 and 9 maintenance branches.

But as of today I would suggest the sensible way is to upgrade Electron to 11+, as that has to happen for all apps anyway sooner than later.

Confirmed it broke in https://github.com/electron/electron/compare/v10.1.5...v10.1.6, so https://github.com/electron/electron/pull/26241 seems like a likely culprit. It’s still unclear to me why it’s fixed in v11.0.0-nightly.20200525 though as the range https://github.com/electron/electron/compare/v10.4.2...v11.0.0-nightly.20200525 contains nothing obviously related.

@mahnunchik yep, exactly. It’s broken in 10.4.2 and fixed in 11.0.0.

@ckerr any chance to have a fix for this issue with electron 9 and 10 ? Thanks

For all with this issue, it seems that getLocale() works again fine since electron v11.1.1 !