laravel-modules icon indicating copy to clipboard operation
laravel-modules copied to clipboard

Problems with the translation system and loadJsonTranslationsFrom()

Open Rattone opened this issue 2 years ago • 0 comments

I'm having problems translating static texts of my modules (Laravel 8) and analyzing I found several inconsistencies, at least I think.

First, I noticed that this commit https://github.com/nWidart/laravel-modules/commit/3b1285084019d25eb08619d5bfb1f958d17c2a47 introduced JSON translations by default, great, but the function loadJsonTranslationsFrom require only one parameter and 2 are passed.

  • Laravel API Docs: https://laravel.com/api/9.x/Illuminate/Support/ServiceProvider.html#method_loadJsonTranslationsFrom

I also noticed that the package "publishes" the module translations under the resources/lang/{$name} folder, instead the stub points to the 'lang/modules/' . $this->moduleNameLower folder.

  • module:publish-translation command that call LangPublisher https://github.com/nWidart/laravel-modules/blob/master/src/Commands/PublishTranslationCommand.php

  • LangPublisher with /resources/lang/ https://github.com/nWidart/laravel-modules/blob/master/src/Publishing/LangPublisher.php#L25

  • Stub with /resources/lang/module/ https://github.com/nWidart/laravel-modules/blob/master/src/Commands/stubs/scaffold/provider.stub#L83

The documentation is also very unclear about how translations work

Rattone avatar Oct 03 '22 15:10 Rattone