Keep language preference between page refreshes

See original GitHub issue

That seems a very basic issue, but I couldn’t find the answer anywhere.

After I change the language using:

i18n.changeLanguage(lng);

Everything updates as expected. But if I refresh the page it goes back to default language. How do I keep language preferences between page refreshes?

Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

11reactions
dougsouzacommented, Feb 11, 2020

Solved by removing lng in init().

8reactions
ragheedaloudehcommented, Nov 16, 2020

i fix the problem before lng: ‘ar’ and thats back to defualt language when reload the page after lng: localStorage. getItem(key) || ‘ar’ thats will go to default language after first load when there’s no localStorage and when reload if there’s a localStorage it will remember the choices.

thank you for help

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keep language preference after page refresh from ...
How to keep the English language after refreshing the page? The default language is NL, when I switch English and after the refresh, ......
Read more >
Language change without full page reload - Vue Storefront Docs
By default, language changes cause a full page reload. To not trigger a full reload, you can change your i18n configuration (opens new...
Read more >
Save State to LocalStorage & Persist on Refresh with React.js
Learn how to save React state and load it when a page refreshes using localStorage. We'll learn how to set up a simple...
Read more >
How to properly internationalize a React application using ...
We are going to adapt the app to detect the language according to the user's preference. And we will create a language switcher...
Read more >
How to translate React application with react-i18next - part 2
But wait — if we change the language and refresh the page, the language will reset to default one. Why? Because we don't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found