this.$moment().locale(lang) does not works
See original GitHub issueHello, I want to change locale with a user click event on button.
I have the following
// main.js
import Vue from 'vue'
import VueMoment from 'vue-moment'
const moment = require('moment')
require('moment/locale/en-gb')
require('moment/locale/fr')
Vue.use(VueMoment, {
moment
})
And then, using in component:
// app.vue
<script>
methods: {
setLanguage (lang) {
console.log(lang)
this.$moment().locale(lang)
console.log(this.$moment().locale())
}
}
}
</script>
When I call the function from the button, I got the following
setLanguage('en')
en
fr
setLanguage('fr')
fr
fr
Is it possible to update the moment locale this way?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top Results From Across the Web
moment.js change locale not working - Stack Overflow
My website is a mutilanguage website, when I change the web language. moment.locale(lang) not working. My code is: const startDate = moment.utc( ...
Read more >locale changes does'nt work · Issue #2962 · moment ... - GitHub
When I try to change the locale value, nothing happens, not even error. this.$log.log(moment.locale()); // returns 'en' this.
Read more >Changing locales locally - momentjs.com
If you call moment#locale with no parameters, you get back the locale configuration that would be used for that moment. var fr =...
Read more >Docs - Moment.js
Moment doesn't work well with modern "tree shaking" algorithms, so it tends to increase the size of web application bundles.
Read more >Beginning JavaScript I18n with i18next and Moment.js | Phrase
The team is working with React for a view layer. ... Locale output (for say, a language switcher); Fallback to default ... get...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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
I think this is fixed now
nuxt 1 import ‘moment/locale/th’
2
moment(date) { // moment.locale(‘th’); var strdate = moment(“th”).format(“LLLL”); var strdate = moment(date).add(543, “years”); return moment(strdate).format(“Do MMMM YYYY hh:mm”); },