electron/spec/fixtures/api/locale-check/main.js
Raymond Zhao 5fc3ed936e
feat: add app.getPreferredSystemLanguages() API (#36035)
* feat: add app.getSystemLanguage() API

* Change the API to getPreferredSystemLanguages

* Fix test

* Clarify docs and add Linux impl

* Remove USE_GLIB

* Don't add C to list

* Remove examples since there's a lot of edge cases

* Fix lint

* Add examples

* Fix compile error

* Apply PR feedback

* Update the example
2022-11-09 10:50:43 -05:00

17 lines
469 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()}|${JSON.stringify(app.getPreferredSystemLanguages())}`);
}
process.stdout.end();
app.quit();
});