xiCO2k / laravel-vue-i18n

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

Translation json files are not created when running `npm run build` #98

Closed cliche23 closed 1 year ago

cliche23 commented 1 year ago

Hi!

I have a problem with translation json files not being generated when deploying to production and building assets with npm run build. When doing local development and running npm run dev everything works fine and the files are created. I am using Vite as an asset bundler and I have added the plugin in Vite config as described in readme file. Am I missing something?

xiCO2k commented 1 year ago

Can share your folder structure and the app.js file?

Thanks.

cliche23 commented 1 year ago

Folder structure is as usual for Laravel 9 translation files.

<project root>
  lang/
    lv/

app.js

import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { i18nVue } from 'laravel-vue-i18n';
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';
import { createVuetify } from 'vuetify'
import * as components from 'vuetify/components';
import * as directives from 'vuetify/directives';
import Axios from 'axios';
import { createPinia } from 'pinia';
import SimpleTypeahead from 'vue3-simple-typeahead';
import { FocusTrap } from 'focus-trap-vue'

createInertiaApp({
    resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
    setup({ el, App, props, plugin }) {
        const vuetify = createVuetify({
            theme: false,
            components,
            directives
        });
        const app = createApp({ render: () => h(App, props) });
        app.provide('$http', Axios);
        app.use(i18nVue, {
            resolve: async lang => {
                const langs = import.meta.glob('../../lang/*.json');
                if (typeof langs[`../../lang/${lang}.json`] != "undefined") {
                    return await langs[`../../lang/${lang}.json`]();
                }
            }
        })
        .use(vuetify)
        .use(createPinia())
        .use(ZiggyVue, Ziggy)
        .use(plugin)
        .use(SimpleTypeahead)
        .component('FocusTrap', FocusTrap)
        .mount(el)
    },
});
koyhl commented 1 year ago

I had a similar situation to him

xiCO2k commented 1 year ago

Could not replicate it.