electron/spec/fixtures/api/locale-check/main.js
Raymond Zhao 8a0b4fa338
feat: add app.getSystemLocale() method (#35697)
* feat: add app.getSystemLocale() method

* Update shell/browser/electron_browser_main_parts.cc

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* Change methods to be const

* Apply PR feedback

* Fix mac compile

* Add missing scope

* Apply style changes

* Change note

* Add braces to get the comment indentation right

* Change to static

* Apply PR feedback

* Fix the documentation

* Remove extraneous file

Co-authored-by: Charles Kerr <charles@charleskerr.com>
2022-09-23 11:50:46 -07:00

17 lines
416 B
JavaScript

const { app } = require('electron');
const locale = process.argv[2].substr(11);
if (locale.length !== 0) {
app.commandLine.appendSwitch('lang', locale);
}
app.whenReady().then(() => {
if (process.argv[3] === '--print-env') {
process.stdout.write(String(process.env.LC_ALL));
} else {
process.stdout.write(`${app.getLocale()}|${app.getSystemLocale()}`);
}
process.stdout.end();
app.quit();
});