Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save user language setting to backend #2784

Merged
merged 12 commits into from
Mar 8, 2019

Conversation

awarecan
Copy link
Contributor

@awarecan awarecan commented Feb 18, 2019

fixes: #2740

  • Save language selection to backend's "frontend per user storage"

  • Still save/load selected language from local app storage, but the backend storage will override local storage

  • Use local app stored language or browser language setting before login (might add language selection in login form, out of this PR's scope)

  • Add support for zh-MY and zh-MO locales

  • Convert themes-mixin.js to TypeScript

  • Convert ha-pref-storage.js to TypeScript

@ghost ghost assigned awarecan Feb 18, 2019
@ghost ghost added the in progress label Feb 18, 2019
@balloob
Copy link
Member

balloob commented Feb 18, 2019

I think it would make most sense if we treat the backend storage as a sync, but don't integrate it with the translations startup code. That will keep the app faster to load and keep the code cleaner.

  • Keep storing language pref in local storage and we'll load from that on page load
  • On page load, query the backend make sure the language is up to date, and call setLanguage if it is not. Do this call async, not blocking further startup. A one time sync post-login to set the language is totally fine.
  • Set language will behave normally, storing it in local storage. Will also send request to the backend.

@awarecan
Copy link
Contributor Author

Address some review comment, all functions worked as expected excepted no local app storage yet.

I am still want to refactor the whole translation/language code base to make the flow more clearly to follow balloob's suggestion. More commits are coming

src/types.ts Show resolved Hide resolved
Copy link
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok to merge when final comments addressed 🎉

@awarecan awarecan merged commit f809bf0 into home-assistant:dev Mar 8, 2019
@ghost ghost removed the in progress label Mar 8, 2019
@awarecan awarecan deleted the save-user-pref branch March 8, 2019 10:50
@balloob balloob mentioned this pull request Mar 12, 2019
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store/restore preferred language in user prefs
3 participants