contact934
contact934

Reputation: 21

How can I add 'System Language' as a language option in the settings of an Electron app?

I would like to add 'System Language' as a language option in the settings of an Electron app. I searched for keywords: 'language' and 'system language' through the Electron documentation but I could not find anything useful.

Where can I find documentation to help me understand how 'System Language' can be added as a language option in the settings of an Electron app?

Or, how can I add 'System Language' as a language option in the settings of an Electron app?

Upvotes: 2

Views: 5883

Answers (2)

raziEiL
raziEiL

Reputation: 87

Electron now has a app.getLocale function to get locale in main process

Upvotes: 1

Erick
Erick

Reputation: 1255

You can use the browser's navigator.language API, which returns the user's preferred language according to the BCP 47 spec. Note that this API is only available in the renderer process, so you'll have to use IPC to call it from your main process if that's what you want.

const lang = navigator.language;
console.log(lang); // e.g. "en-US", "fr", "es-ES", etc.

Upvotes: 4

Related Questions