xiCO2k / laravel-vue-i18n

Allows to connect your `Laravel` Framework translation files with `Vue`.
MIT License
606 stars 50 forks source link

Language switches from english to the selected language #162

Open JonasCykelgear opened 8 months ago

JonasCykelgear commented 8 months ago

Im having this problem where my language starts at english then switches to danish a moment after. It happens when i run in ssr mode.

You can see it happen here - Look at the "Mærker" text, then refresh the page: https://www.cykelgear.dk/

ssr.js:

.use(i18nVue, {
    lang: 'da',
    resolve: lang => {
        const langs = import.meta.glob('../../lang/*.json', { eager: true });
        return langs[`../../lang/${lang}.json`].default;
    },
})

app.js:

.use(i18nVue, {
    lang: 'da',
    resolve: lang => {
        const langs = import.meta.glob('../../lang/*.json', { eager: true });
        return langs[`../../lang/${lang}.json`].default;
    },
})

Let me know if any information is needed

xiCO2k commented 8 months ago

Thanks for the report, I did check your view-source: and looks like the only work not translating on the ssr is the "Brands" all the rest looks good.

any hints?

JonasCykelgear commented 8 months ago

Yeah. Some of the texts are from the DB which doesnt get translated if that makes sense.

This only happens to texts that gets translated in vue files using the $t function. Also only in ssr mode. When i run the project locally everything works fine.

Here might be a better example, if you look at the product pricing and stock information: https://www.cykelgear.dk/tilbehor/olie-fedt-vedligehold/kaedeolie-og-voks/muc-off-dry-lube-120ml