fixed up language
This commit is contained in:
parent
9822ebc3bf
commit
a5b3840d06
4 changed files with 49 additions and 34 deletions
|
|
@ -1,24 +1,13 @@
|
|||
import Cookies from 'js-cookie'
|
||||
|
||||
import { useEmojiStore } from 'src/stores/emoji.js'
|
||||
import { useI18nStore } from 'src/stores/i18n.js'
|
||||
|
||||
import messages from 'src/i18n/messages'
|
||||
import localeService from 'src/services/locale/locale.service.js'
|
||||
|
||||
const BACKEND_LANGUAGE_COOKIE_NAME = 'userLanguage'
|
||||
|
||||
export const piniaLanguagePlugin = ({ store, options }) => {
|
||||
if (store.$id === 'sync_config') {
|
||||
store.$onAction(({ name, args }) => {
|
||||
const { path, value } = args[0]
|
||||
if (name === 'setPreference' && path === 'simple.interfaceLanguage') {
|
||||
messages.setLanguage(useI18nStore().i18n, value)
|
||||
useEmojiStore().loadUnicodeEmojiData(value)
|
||||
Cookies.set(
|
||||
BACKEND_LANGUAGE_COOKIE_NAME,
|
||||
localeService.internalToBackendLocaleMulti(value),
|
||||
)
|
||||
if (name === 'setPreference') {
|
||||
const { path, value } = args[0]
|
||||
if (path === 'simple.interfaceLanguage') {
|
||||
useI18nStore().setLanguage(value)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue