refs #527 Set locale for moment

This commit is contained in:
AkiraFukushima 2018-08-31 01:08:07 +09:00
parent ab54cbac53
commit 868598fe7f
4 changed files with 16 additions and 4 deletions

View File

@ -108,7 +108,8 @@ export default {
computed: {
...mapState({
displayNameStyle: state => state.App.displayNameStyle,
timeFormat: state => state.App.timeFormat
timeFormat: state => state.App.timeFormat,
language: state => state.App.language
}),
shortcutEnabled: function () {
return this.focused && !this.overlaid
@ -145,6 +146,7 @@ export default {
case TimeFormat.Absolute.value:
return moment(datetime).format('YYYY-MM-DD HH:mm:ss')
case TimeFormat.Relative.value:
moment.locale(this.language)
return moment(datetime).fromNow()
}
},

View File

@ -107,7 +107,8 @@ export default {
},
computed: {
...mapState({
timeFormat: state => state.App.timeFormat
timeFormat: state => state.App.timeFormat,
language: state => state.App.language
}),
shortcutEnabled: function () {
return this.focused && !this.overlaid
@ -144,6 +145,7 @@ export default {
case TimeFormat.Absolute.value:
return moment(datetime).format('YYYY-MM-DD HH:mm:ss')
case TimeFormat.Relative.value:
moment.locale(this.language)
return moment(datetime).fromNow()
}
},

View File

@ -152,7 +152,8 @@ export default {
computed: {
...mapState({
displayNameStyle: state => state.App.displayNameStyle,
timeFormat: state => state.App.timeFormat
timeFormat: state => state.App.timeFormat,
language: state => state.App.language
}),
shortcutEnabled: function () {
return this.focused && !this.overlaid
@ -216,6 +217,7 @@ export default {
case TimeFormat.Absolute.value:
return moment(datetime).format('YYYY-MM-DD HH:mm:ss')
case TimeFormat.Relative.value:
moment.locale(this.language)
return moment(datetime).fromNow()
}
},

View File

@ -5,6 +5,7 @@ import Visibility from '~/src/constants/visibility'
import DisplayStyle from '~/src/constants/displayStyle'
import Theme from '~/src/constants/theme'
import TimeFormat from '~/src/constants/timeFormat'
import Language from '~/src/constants/language'
const App = {
namespaced: true,
@ -19,7 +20,8 @@ const App = {
favourite: true,
follow: true
},
timeFormat: TimeFormat.Absolute.value
timeFormat: TimeFormat.Absolute.value,
language: Language.en.key
},
mutations: {
updateTheme (state, themeKey) {
@ -49,6 +51,9 @@ const App = {
},
updateTimeFormat (state, format) {
state.timeFormat = format
},
updateLanguage (state, key) {
state.language = key
}
},
actions: {
@ -75,6 +80,7 @@ const App = {
commit('updateTootVisibility', conf.general.tootVisibility)
commit('updateNotify', conf.notification.notify)
commit('updateTimeFormat', conf.general.timeFormat)
commit('updateLanguage', conf.language.language)
resolve(conf)
})
})