Closed nathanwalasek closed 2 years ago
Hey, inertia.js is not required, can you show me the .use(i18nVue
part on your app? Thanks
Yes! Thank you for the quick reply:
// Localization
app.use(i18nVue, {
resolve: lang => import(`../lang/${lang}.json`)
})
const mounted = app.mount('#app')
I have been able to successfully use the XX.json files in my components like this:
{{ $t('Hello') }}
and
trans('Hello')
However, using the PHP files like trans('auth.failed')
does not work (it simply outputs 'auth.failed')
I believe it's because the plugin in Webpack is either not running correctly, or is not able to access my PHP language files located in /resources/lang/en/
The issue is probably related with not being able to get the php
files.
Can you go under the the node_modules/laravel-vue-i18n/dist/mix.js
, search for this.langPath =
and add a console.log(this.langPath);
on the line right after.
Go ahead and run the build, then can you make sure the langPath
is correct and share the output of the log with me?
Thanks.
I apologize, the issue seems to have worked itself out. Yesterday I had uninstalled laravel-vue-i18n to try a different approach, and just now re-installed to troubleshoot after I received your reply.
I ran the build and this time, it is processing the PHP files:
js/resources_lang_en_json.js │ 1.27 KiB │
js/resources_lang_es_json.js │ 1.27 KiB │
js/resources_lang_fr_json.js │ 1.26 KiB │
js/resources_lang_php_en_json.js │ 7.77 KiB │
js/resources_lang_php_es_json.js │ 8.21 KiB │
js/resources_lang_php_fr_json.js │ 8.5 KiB │
I'm not sure what the original issue was, but thanks again for your help!
Thats great, thanks for reporting.
I have the same problem (Laravel 8, webpack.mix.js). Try debug console.log(this.langPath); https://github.com/xiCO2k/laravel-vue-i18n/issues/23#issuecomment-1090971266 I don't see anything after npm run dev and page refresh. What am I doing wrong?
I'm following your instructions to have Webpack process the PHP language files (located in my /resources/lang/ directory for Laravel < v9.0)
I have this at the top of my webpack.mix.js file:
const mix = require('laravel-mix'); require('laravel-vue-i18n/mix');
And I'm using the plugin like so:
.i18n('resources/lang')
Webpack compiles successfully but it does not process my PHP language files (only the .json files). This is the only language files in the Laravel Mix output:
js/resources_lang_en_json.js │ 1.27 KiB │
js/resources_lang_es_json.js │ 1.27 KiB │
js/resources_lang_fr_json.js │ 1.26 KiB │
Any suggestions? Is it required to use Inertia.js?