mirror of https://github.com/nocodb/nocodb
Braks
2 years ago
committed by
Pranav C
2 changed files with 19 additions and 4 deletions
@ -1,11 +1,23 @@
|
||||
import { defineNuxtPlugin } from '#app' |
||||
import { useGlobalState } from '~/composables/useGlobalState' |
||||
|
||||
/** |
||||
* Injects global state into nuxt app. |
||||
* |
||||
* @example |
||||
* ```js
|
||||
* import { useNuxtApp } from '#app' |
||||
* |
||||
* const { $state } = useNuxtApp() |
||||
* |
||||
* console.log($state.lang.value) // 'en'
|
||||
* ``` |
||||
*/ |
||||
export default defineNuxtPlugin((nuxtApp) => { |
||||
const storage = useGlobalState() |
||||
|
||||
// set initial app language to the first preferred language (found in state)
|
||||
;(nuxtApp.vueApp as any).i18n.locale.value = storage.lang.value |
||||
/** set i18n locale to stored language */ |
||||
nuxtApp.vueApp.i18n.locale = storage.lang.value |
||||
|
||||
nuxtApp.provide('state', storage) |
||||
}) |
||||
|
Loading…
Reference in new issue