laravel-vue-i18n: Cannot read properties of undefined (reading 'VITE_LARAVEL_VUE_I18N_HAS_PHP')
- laravel-vue-i18n - 2.1.1
- vite - 2.9.9
- vuejs 3.2.25
- node 16.16.0
- without laravel
// .env
VITE_LARAVEL_VUE_I18N_HAS_PHP=false
// src/main.ts
import { createApp } from 'vue'
import { i18nVue } from 'laravel-vue-i18n'
import i18nOptions from '@/utils/lang'
import pinia from '@/utils/pinia'
createApp(App)
.use(i18nVue, i18nOptions(pinia))
// src/utils/lang
import { Pinia } from 'pinia'
import { useSettingsStore } from '@/stores/settings'
export default (pinia: Pinia) => {
const lang = useSettingsStore(pinia).locale
const resolve = async (lang: string) => {
const files = import.meta.glob('../../lang/*.json')
return await files[`../../lang/${ lang }.json`]()
}
return { lang, resolve }
}

Result: not working

If we add output to the console, we see that the files are loaded:
const resolve = async (lang: string) => {
const files = import.meta.glob('../../lang/*.json')
console.log(files)
console.log(
import.meta.env.VITE_API_URL,
import.meta.env.VITE_LARAVEL_VUE_I18N_HAS_PHP
)
return await files[`../../lang/${ lang }.json`]()
}


Without the VITE_LARAVEL_VUE_I18N_HAS_PHP key, I also get the error:

Version 1.4.4 worked perfectly.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (19 by maintainers)
Commits related to this issue
- Fix for #49 — committed to andrey-helldar/laravel-vue-i18n by deleted user 2 years ago
Awesome, will tag it
Thanks for the PR, can you try again, and let me know?
really interesting case, will try to debug.
Thanks for all the help @andrey-helldar.