xiCO2k / laravel-vue-i18n

Allows to connect your `Laravel` Framework translation files with `Vue`.
MIT License
598 stars 49 forks source link

Support for Laravel Modules #78

Closed quelo83 closed 8 months ago

quelo83 commented 1 year ago

Hi, my project uses the Laravel Modules package (https://github.com/nWidart/laravel-modules) which allows you to separates logic in different modules. This means that every module has its own lang files.

The problem is that it is not possible to specify more than one folder for PHP files in the Vite plugin.

export default function i18n(langPath: string = 'lang')

It would be perfect if it accepts an array of LangPaths in order to process more than one folder.

Is this a possible change?

xiCO2k commented 1 year ago

Hey @quelo83 will take a look on that and find if that is possible to add to the plugin.

Thanks.

quelo83 commented 1 year ago

Thank you very much @xiCO2k. This would be a fantastic improvement.

I've not tested yet, but it seems that the only changes would be to modify the function header to accept an array of langPaths:

export default function i18n(langPath: string|string[] = 'lang') {

and replace the line 22:

files = parseAll(langPath)

with this code:

let langPaths = Array.isArray(langPath) ? langPath : [langPath];

langPaths.forEach(langPath => {
  files = files.concat(parseAll(langPath));
});

Let me know if I can help you in any way.

RomanNebesnuyGC commented 1 year ago

++ need this feature also

mpietrucha commented 1 year ago

+1 also it could help to exclude some unwanted in frontend files as for example validation

SVANNER commented 1 year ago

Hi I also look for this kind of features. I would like to be able to load lang files in a specific context. Indeed, a single lang file become quickly big impacting performance. Having the opportunity to load multiple lang files by module is an important feature for me. For example there is no need to load translations related for one shot Vue 3 pages like setup checks every time in the other Vue 3 pages components are loaded.

xiCO2k commented 8 months ago

Don't think I have the time to take a look on this, will be glad to check a PR.

lionslair commented 6 months ago

I got the same issue with modules exported to lang/vendor/... would a pr for the above work?

as a temp fix going to publish inside the lang/en/ folder