最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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 badges
Add a ment  | 

2 Answers 2

Reset to default 4

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.

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论