11import './bootstrap' ;
2- import i18n from 'vue-banana-i18n' ;
32import { createStore } from './store' ;
4- import i18nMessages from './lib/i18n' ;
53import { createApp , h } from 'vue' ;
64import { createInertiaApp } from '@inertiajs/inertia-vue3' ;
5+ import i18nMessages , { I18nMessages } from './lib/i18n' ;
6+ import { createI18n } from 'vue-banana-i18n'
77import bubble from './lib/bubble' ;
88import Error from './Pages/Error.vue' ;
99import Layout from './Pages/Layout.vue' ;
1010
1111Vue . use ( bubble ) ;
1212
1313// Retrieve i18n messages and setup the Vue instance to handle them.
14- async function setupI18n ( locale : string ) : Promise < void > {
15- const messages = await i18nMessages ( locale ) ;
16- Vue . use ( i18n , { locale, messages } ) ;
14+ async function setupI18n ( locale : string ) : Promise < I18nMessages > {
15+ return await i18nMessages ( locale ) ;
1716}
1817
1918// Only bootstrap inertia if setup is successful. Display generic error
2019// component otherwise
2120( async ( ) => {
2221 try {
23- await setupI18n ( document . documentElement . lang ) ;
2422 const store = createStore ( ) ;
25-
23+ const locale = document . documentElement . lang ;
24+ const i18nMessages = await setupI18n ( locale ) ;
25+ const i18nPlugin = createI18n ( {
26+ locale : locale ,
27+ messages : i18nMessages
28+ } ) ;
2629 createInertiaApp ( {
2730 resolve : name => {
2831 const page = require ( `./Pages/${ name } ` ) . default ;
@@ -35,6 +38,7 @@ async function setupI18n(locale: string): Promise<void>{
3538 createApp ( {
3639 render : ( ) => h ( app , props )
3740 } )
41+ . use ( i18nPlugin )
3842 . use ( plugin )
3943 . mount ( el )
4044 }
0 commit comments