Skip to content

Commit cc841a2

Browse files
committed
[vue] clean up
1 parent 0eca63a commit cc841a2

File tree

6 files changed

+11
-35
lines changed

6 files changed

+11
-35
lines changed

README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,6 @@ php artisan kui-fortify:install blade # This command will publish laravel/fortif
3838

3939
# then
4040
npm install && npm run dev # or yarn && yarn dev
41-
42-
# Laravel mix will compile successfully, but with 1 warning `Module not found: Error: Can't resolve '../../lang'`.
43-
# It will work but you can fix it by remove trycatch in `app.js` and import lang file like this:
44-
45-
# laravel 9
46-
# resolve: (lang) => import(`../../lang/${lang}.json`),
47-
48-
# laravel < 9
49-
# resolve: (lang) => import(`../lang/${lang}.json`),
50-
51-
# Until we fix it.
5241
```
5342

5443
4. Configure your database.

src/Console/InstallCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,11 @@ protected function installVue()
235235
);
236236

237237
// Lang File
238-
if ((new Filesystem)->exists(resource_path('lang'))) {
238+
if ((new Filesystem)->exists(resource_path('lang'))) { // Laravel < 9
239239
copy(__DIR__ . '/../../stubs/vue/lang/ar.json', resource_path('lang/ar.json'));
240-
} else if ((new Filesystem)->exists(base_path('lang'))) {
240+
copy(__DIR__ . '/../../stubs/vue/lang/en.json', resource_path('lang/en.json'));
241+
} else if ((new Filesystem)->exists(base_path('lang'))) { // Laravel 9
242+
$this->replaceInFile('../lang', '../../lang', resource_path('js/app.js'));
241243
copy(__DIR__ . '/../../stubs/vue/lang/ar.json', base_path('lang/ar.json'));
242244
}
243245

stubs/vue/lang/ar.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{}
1+
{
2+
"Dashboard": "لوحة التحكم"
3+
}

stubs/vue/lang/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"Dashboard": "Dashboard"
3+
}

stubs/vue/resources/js/app.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ import { createInertiaApp } from '@inertiajs/inertia-vue3';
55
import { InertiaProgress } from '@inertiajs/progress';
66
import { i18nVue } from 'laravel-vue-i18n';
77
import Toast from 'vue-toastification';
8-
import composer from '../../composer.json';
9-
10-
const isLaravel9 = composer.require["laravel/framework"].startsWith("^9.")
11-
? true
12-
: false;
138

149
const appName =
1510
window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';
@@ -21,18 +16,7 @@ createInertiaApp({
2116
return createApp({ render: () => h(app, props) })
2217
.use(plugin)
2318
.use(i18nVue, {
24-
// TODO: Use a real solution.
25-
resolve: (lang) => {
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-
}
35-
},
19+
resolve: (lang) => import(`../lang/${lang}.json`),
3620
})
3721
.use(Toast, {
3822
hideProgressBar: true,

stubs/vue/resources/views/app.blade.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,5 @@
2121
</head>
2222
<body class="font-sans antialiased">
2323
@inertia
24-
25-
@env ('local')
26-
<script src="http://localhost:8080/js/bundle.js"></script>
27-
@endenv
2824
</body>
2925
</html>

0 commit comments

Comments
 (0)