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 }
}

image

Result: not working

image

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`]()
}

image

image

Without the VITE_LARAVEL_VUE_I18N_HAS_PHP key, I also get the error:

image

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

Most upvoted comments

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.