Auto-detect OS user language #2955

Closed
opened 2019-10-02 23:56:27 +02:00 by kodxana · 12 comments
kodxana commented 2019-10-02 23:56:27 +02:00 (Migrated from github.com)

Is your feature request related to a problem? Please describe.
Need manualy find and implement other Languages.

Describe the solution you'd like
App should pull informations from OS about user language, and try set translation automatic, or prompt user if he want use his native language or stay in English. If Transfix return no translation for that language it should set it to default English.

**Is your feature request related to a problem? Please describe.** Need manualy find and implement other Languages. **Describe the solution you'd like** App should pull informations from OS about user language, and try set translation automatic, or prompt user if he want use his native language or stay in English. If Transfix return no translation for that language it should set it to default English.
tzarebczan commented 2019-10-03 15:05:02 +02:00 (Migrated from github.com)

Great suggestion!

Great suggestion!
kodxana commented 2019-10-03 16:43:22 +02:00 (Migrated from github.com)

Suggestion how to get is locale https://github.com/sindresorhus/os-locale

Suggestion how to get is locale https://github.com/sindresorhus/os-locale
peterjgrainger commented 2019-10-04 16:45:42 +02:00 (Migrated from github.com)

Can I have a go at this one?

Can I have a go at this one?
tzarebczan commented 2019-10-04 17:02:54 +02:00 (Migrated from github.com)

@peterjgrainger welcome to LBRY! Sure, take a stab at it!

@peterjgrainger welcome to LBRY! Sure, take a stab at it!
kauffj commented 2019-10-04 22:33:17 +02:00 (Migrated from github.com)

@peterjgrainger FYI language is being accessed before UI loads on both web (where this is probably necessary) and desktop (where it's probably not necessary but was more efficient from development perspective).

You can see this in index-web.html and index-electron.html. If you have any questions, don't hesitate to tag me!

@peterjgrainger FYI language is being accessed before UI loads on both web (where this is probably necessary) and desktop (where it's probably not necessary but was more efficient from development perspective). You can see this in `index-web.html` and `index-electron.html`. If you have any questions, don't hesitate to tag me!
Rupeshiya commented 2019-10-05 16:33:54 +02:00 (Migrated from github.com)

@kauffj Can I work on this?
I think simply can be done using https://github.com/sindresorhus/os-locale.

@kauffj Can I work on this? I think simply can be done using https://github.com/sindresorhus/os-locale.
peterjgrainger commented 2019-10-06 10:38:08 +02:00 (Migrated from github.com)

@kauffj thanks for the offer of help will probably need it!

Just getting the project set up now

@kauffj thanks for the offer of help will probably need it! Just getting the project set up now
peterjgrainger commented 2019-10-10 17:54:33 +02:00 (Migrated from github.com)

@kauffj my thought is to use the app.getLocale() builtin function in electron https://github.com/electron/electron/blob/master/docs/api/app.md#appgetlocale

would the best place to put that be here? 6471aa2140/src/platforms/electron/index.js (L40-L43)

I see that you can change the language in Settings. Would that cover the ask in the original issue do you think?

@kauffj my thought is to use the `app.getLocale()` builtin function in electron https://github.com/electron/electron/blob/master/docs/api/app.md#appgetlocale would the best place to put that be here? https://github.com/lbryio/lbry-desktop/blob/6471aa2140708f2ca3aaa5c15513ef4d02ceacbd/src/platforms/electron/index.js#L40-L43 I see that you can change the language in Settings. Would that cover the ask in the original issue do you think?
kauffj commented 2019-10-10 23:43:13 +02:00 (Migrated from github.com)

@peterjgrainger yes, app.getLocale() is the way to go. If we want this to work on both desktop and web, then there are probably two changes to make:

  1. For desktop, use app.getLocale() to set the language before rendering index.html. I believe you'll need to do this in createWindow.js somewhere between creating the window and the call to loadURL.
  2. For web, use NavigatorLanguage to set the language directly in index-web.html.

In both cases, if language is already set on window.localStorage, that value should take precedence.

Also note that our language files are currently only two letters rather than the 4 letter language + locale codes. If either app.getLocale or NavigatorLanguage return 4 letter codes, the language portion needs to be stripped off of this value.

Please also ensure your code works in the cases that the detected language is not one we support.

Thanks @peterjgrainger!

@peterjgrainger yes, `app.getLocale()` is the way to go. If we want this to work on both desktop and web, then there are probably two changes to make: 1. For desktop, use `app.getLocale()` to set the language _before_ rendering `index.html`. I believe you'll need to do this in `createWindow.js` somewhere between creating the window and the call to `loadURL`. 1. For web, use [NavigatorLanguage](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language) to set the language directly in `index-web.html`. In both cases, if language is already set on `window.localStorage`, that value should take precedence. Also note that our language files are currently only two letters rather than the 4 letter language + locale codes. If either `app.getLocale` or `NavigatorLanguage` return 4 letter codes, the language portion needs to be stripped off of this value. Please also ensure your code works in the cases that the detected language is not one we support. Thanks @peterjgrainger!
peterjgrainger commented 2019-10-11 16:09:36 +02:00 (Migrated from github.com)

@kauffj Can you have a look at the PR and let me know if I am on the right track?

I'll do the web side as well. I'm pretty new to Electron and React so please let me know if I'm doing something wrong!

@kauffj Can you have a look at the PR and let me know if I am on the right track? I'll do the web side as well. I'm pretty new to Electron and React so please let me know if I'm doing something wrong!
jsigwart commented 2019-11-12 07:17:52 +01:00 (Migrated from github.com)

I was looking to file a new issue, but then saw this one. What I was going to file was a suggestion for the language selection menu to be moved from Settings and onto the Home page (an obvious place). Imagine the UX if you speak Chinese and have to try to navigate through an English interface to search for where you can select your native language - not fun.

I wasn't sure how soon this issue would be finished, which would probably negate the need for the language selector.

I was looking to file a new issue, but then saw this one. What I was going to file was a suggestion for the language selection menu to be moved from Settings and onto the Home page (an obvious place). Imagine the UX if you speak Chinese and have to try to navigate through an English interface to search for where you can select your native language - not fun. I wasn't sure how soon this issue would be finished, which would probably negate the need for the language selector.
kauffj commented 2019-11-12 23:37:35 +01:00 (Migrated from github.com)

@jsigwart (and @peterjgrainger) this will almost certainly ship in the next release.

Julie, the other change remaining issue to tackle here is https://github.com/lbryio/lbry-desktop/issues/3186 (right now you can only change language if you sign in).

@jsigwart (and @peterjgrainger) this will almost certainly ship in the next release. Julie, the other change remaining issue to tackle here is https://github.com/lbryio/lbry-desktop/issues/3186 (right now you can only change language if you sign in).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/lbry-desktop#2955
No description provided.