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?
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?
Share Improve this question edited Apr 4, 2020 at 11:00 contact934 asked Apr 3, 2020 at 13:53 contact934contact934 211 silver badge4 bronze badges2 Answers
Reset to default 4You 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.
Electron now has a app.getLocale function to get locale in main process