-
Notifications
You must be signed in to change notification settings - Fork 244
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
Language switching and local storage persistence #735
Conversation
Hey @ajparise, thanks for your PR. Does it need a review yet? |
@nalbina It's ready for a review. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far. I added some comments to naming and behaviour when clicking on an already selected language.
client/templates/home/footer.js
Outdated
const languageCode = event.target.dataset.langCode | ||
const languageName = event.target.dataset.langName | ||
|
||
TAPi18n.setLanguage(languageCode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like setting the same language again should be a noop. right now I am getting a notification for each click.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense and was intentional, but valid point. I added a guard clause.
client/templates/home/footer.js
Outdated
console.log(error); | ||
}) | ||
.always(() => { | ||
localStorage.setItem('lang', TAPi18n.getLanguage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call the localstorage item also languageCode to stay in sync with the rest? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, updated in all related files.
client/templates/main.js
Outdated
@@ -9,14 +9,14 @@ if (Meteor.isClient) { | |||
} | |||
|
|||
const defaultLang = 'en' | |||
const urlLang = FlowRouter.getQueryParam('lang') | |||
const localStorageLang = localStorage.getItem('lang'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call the localstorage item also languageCode to stay in sync with the rest? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
Supplements #446, #730.
TAPi18n.getLanguages()