Issue with loading translations from nested folders
See original GitHub issueHi,
Using Laravel 7.x and the v1.0.2 version of this package.
I’m having an issue when generating translations in nested folders.
Example:
Inside the lang/en
folder I have a folder called admin
and here I have a file called master.php
.
When I try to get a key from that file using $t('admin.content.title')
it will return the string 'admin.content.title'
instead of its actual content. But if i put that same file in the root of the lang/en
folder it will return the value correctly. I already tried some variants but so far i couldn’t figure out how to go inside folders.
I tried both configs as stated in the docs:
- First config
Mix:
mix.extend('translations', new class {
webpackRules() {
return {
test: path.resolve(__dirname, 'resources/js/lang/index.js'),
loader: '@kirschbaum-development/laravel-translations-loader/php?parameters={$1}'
}
}
});
mix.translations();
app.js:
import languageBundle from 'resources/lang/index.js';
import VueI18n from 'vue-i18n';
Vue.use(VueI18n);
const i18n = new VueI18n({
locale: window.Locale,
messages: languageBundle,
})
- Second config
app.js:
import languageBundle from '@kirschbaum-development/laravel-translations-loader/php!@kirschbaum-development/laravel-translations-loader';
import VueI18n from 'vue-i18n';
Vue.use(VueI18n);
const i18n = new VueI18n({
locale: window.Locale,
messages: languageBundle,
})
Both don’t work. More, the first config doesnt even create the content inside the index.js
file that i created for the effect.
Could use some help. Maybe i’m doing something wrong, most likely 😛
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Great, that’s good to hear it’s working now. I’ll close this issue.
@Morinohtar Yeah, to load from nested folders you will have to be on the latest version. Also, the
index.js
file you’ve created is not going to receive any content, it only serves as a “fake” to tell webpack where your language files are located, basically.Any change you can post your lang file in here? It seems that some content in there is failing to parse. By any chance, you have any PHP code in the language file? Can you post the content here?