intlify / intlify/nuxt3

Access global property of i18n instance

Open
#76 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
204
Forks
18
PR merge metrics
No merged PRs in 30d

Description

Hi,

is it possible to access the global property of the i18n instance for usage outside of components?
I couldn't find a way, so my current workaround is to use vue-i18n without the nuxt module and create my own plugin which exports i18n instance:

```js
export const i18n = createI18n({
legacy: false,
globalInjection: true,
locale: 'en',
messages: {
en,
},
})

export default defineNuxtPlugin((nuxt) => {
const { vueApp } = nuxt
vueApp.use(i18n)
})
```

Best regards
David

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.