Make LL available globally in Vue templates
#534
nkoehring
started this conversation in
DX improvements
Replies: 1 comment
-
|
I too prefer a global object, but I could not make it work for Vue in a typesafe way. Maybe you can try this: import type { TranslationFunctions } from './i18n/i18n-types'
import { i18nPlugin, typesafeI18n } from './i18n/i18n-vue'
export const setLL = (LL: TranslationFunctions) => app.config.globalProperties.$LL = LL
const app = createApp(App)
app.use(i18nPlugin, detectedLocale)
app.mount("#app")and then call |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, if I understood it right, every component that wants to use translation strings, needs to explicitly import the i18nObject (eg via
const { LL } = typesafeI18n()). It would be great to have it as a global property, usually$t, but I'd understand if you prefer$LLor similar.I tried to achieve this directly in main.ts, but failed:
It seems like LL is not yet initialized at that time. I'm getting
Uncaught TypeError: (intermediate value)() is undefined.Beta Was this translation helpful? Give feedback.
All reactions