Skip to content

Commit 05a9b44

Browse files
committed
[vue] fix
1 parent 530acd9 commit 05a9b44

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

stubs/vue/resources/js/app.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { i18nVue } from 'laravel-vue-i18n';
77
import Toast from 'vue-toastification';
88
import composer from '../../composer.json';
99

10+
const isLaravel9 = composer.require["laravel/framework"].startsWith("^9.")
11+
? true
12+
: false;
13+
1014
const appName =
1115
window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';
1216

@@ -17,14 +21,17 @@ createInertiaApp({
1721
return createApp({ render: () => h(app, props) })
1822
.use(plugin)
1923
.use(i18nVue, {
24+
// TODO: Use a real solution.
2025
resolve: (lang) => {
21-
// TODO: Use a real solution.
22-
const dirLang = composer.require[
23-
"laravel/framework"
24-
].startsWith("^9.")
25-
? `../../lang`
26-
: `../lang`;
27-
import(`${dirLang}/${lang}.json`);
26+
if (isLaravel9) {
27+
try {
28+
return import(`../../lang/${lang}.json`);
29+
} catch (error) {}
30+
} else {
31+
try {
32+
return import(`../lang/${lang}.json`);
33+
} catch (error) {}
34+
}
2835
},
2936
})
3037
.use(Toast, {

0 commit comments

Comments
 (0)