mirror of
https://gitlab.com/omair-personal/exchange.git
synced 2026-08-20 21:14:31 +00:00
33 lines
613 B
JavaScript
33 lines
613 B
JavaScript
import Cookies from 'js-cookie'
|
|
import * as types from '../mutation-types'
|
|
|
|
const { locale, locales } = window.config
|
|
|
|
// state
|
|
export const state = {
|
|
locale: Cookies.get('locale') || locale,
|
|
locales: locales
|
|
}
|
|
|
|
// getters
|
|
export const getters = {
|
|
locale: state => state.locale,
|
|
locales: state => state.locales
|
|
}
|
|
|
|
// mutations
|
|
export const mutations = {
|
|
[types.SET_LOCALE] (state, { locale }) {
|
|
state.locale = locale
|
|
}
|
|
}
|
|
|
|
// actions
|
|
export const actions = {
|
|
setLocale ({ commit }, { locale }) {
|
|
commit(types.SET_LOCALE, { locale })
|
|
|
|
Cookies.set('locale', locale, { expires: 365 })
|
|
}
|
|
}
|