Set locale dynamically at runtime
See original GitHub issueHello,
It unclear to me from the docs if using setLocaleMessage()
is how you get dynamic locales at runtime to work. There are many articles about how to do that at build time, but none that I could see about runtime changes.
To give an example, here is what I mean in the form of a timeline:
- App loads, reads locale requirement.
- Makes AJAX call to fetch the appropriate JSON file (e.g. en.json).
- Calls
setLocaleMessage()
as shown below:
const i18n = new VueI18n({...});
...
i18n.setLocaleMessage('en', {...pathsHere});
...
//Later on:
//After another AJAX call to fetch fr.json:
i18n.setLocaleMessage('fr', {...pathsHere});
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:13
Top Results From Across the Web
Dynamically change the locale in Angular 7 at runtime without ...
I am trying to change Locale_Id in my angular app at the runtime but must use window.location.reload() to fire changes at locale.
Read more >The All-In-One Guide for Changing App Locale Dynamically in ...
xml file specifying the locale. To do so, we will have to follow the steps: File > New > Android Resouce File.
Read more >Android Change Locale Dynamically - Java Articles
In this article, we will show you how to switch between different languages within an app using androids multi-language support.
Read more >Change app default locale dynamically - Laracasts
i'm using mcamara localization package https://github.com/mcamara/laravel-localization in app an with default language set to english as per default laravel ...
Read more >Set the runtime locale manually - Angular
Set the runtime locale manuallylink · Search for the Unicode locale ID in the language-locale combination in the @angular/common/locales/ directory. · Set the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There should be some easy way to change the global language/locale at run-time / dynamically and it should be documented very well and at a central point because this IMHO is an essential feature of this type of library.
Here is my solution:
Usage:
Edit: this works too: