Skip to content

App app.getLocale() API to get application locale - #2800

Merged
zcbenz merged 2 commits into
electron:masterfrom
seanchas116:app-getlocale
Sep 16, 2015
Merged

zcbenz merged 2 commits into
electron:masterfrom
seanchas116:app-getlocale

Conversation

@seanchas116

Copy link
Copy Markdown
Contributor

This PR adds app.getLocale() API to get current locale in main process.

I think this is more reliable than the alternative way that uses os-locale, written in #2274.

@zcbenz

zcbenz commented Sep 16, 2015

Copy link
Copy Markdown
Contributor

Looks good to me, thanks!

zcbenz added a commit that referenced this pull request Sep 16, 2015
App app.getLocale() API to get application locale
@zcbenz
zcbenz merged commit ec7ea30 into electron:master Sep 16, 2015
@nekolab

nekolab commented Oct 14, 2015

Copy link
Copy Markdown
Contributor

Hi @zcbenz
I found app.getLocale() have some wired behavior.
Under OS X, app.getLocale() return different value at "different context".
Under Windows, app.getLocale() always return correct value.
For example:

var app = require('app');
console.log(app.getLocale());    // See en-US in OS X, it's wrong, but correct in Windows
app.on('ready', function() {
  console.log(app.getLocale());  // See zh-CN
});

Not tested in linux.
Is this by design?

@zcbenz

zcbenz commented Oct 14, 2015

Copy link
Copy Markdown
Contributor

It is kind of a platform behavior, OS X seems to load locale information after the application has finished launching, e.g. in the ready event. We probably should document this.

@seanchas116
seanchas116 deleted the app-getlocale branch November 15, 2016 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants