Nuxt/examples/use-state/plugins/locale.server.ts

7 lines
195 B
TypeScript
Raw Normal View History

2021-10-11 17:48:03 +00:00
import { useState } from '#app'
export default defineNuxtPlugin((nuxt) => {
const locale = useState('locale')
locale.value = nuxt.ssrContext.req.headers['accept-language']?.split(',')[0]
})