-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong Lang directory for Laravel 11 #198
Comments
@stefanrakicfaxi I am facing the same problem in my Laravel 11 project. As a temporary solution, you can overwrite the service provider. Create <?php
namespace App\Providers;
use Mariuzzo\LaravelJsLocalization\Commands\LangJsCommand;
use Mariuzzo\LaravelJsLocalization\Generators\LangJsGenerator;
use Mariuzzo\LaravelJsLocalization\LaravelJsLocalizationServiceProvider as BaseLaravelJsLocalizationServiceProvider;
class LaravelJsLocalizationServiceProvider extends BaseLaravelJsLocalizationServiceProvider
{
/**
* There is a problem in v1.11.1 of mariuzzo/laravel-js-localization package.
* So, we overwrite the register method to use the correct path for language files.
*/
public function register(): void
{
$this->app->singleton('localization.js', function () {
$files = $this->app['files'];
$langs = $this->app['path.base'] . '/lang';
$messages = $this->app['config']->get('localization-js.messages');
$generator = new LangJsGenerator($files, $langs, $messages);
return new LangJsCommand($generator);
});
$this->commands('localization.js');
}
} And register it in <?php
return [
App\Providers\AppServiceProvider::class,
App\Providers\LaravelJsLocalizationServiceProvider::class,
]; |
@stefanrakicfaxi @jonaszkadziela This is fixed in #192 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In your LaravelJsLocalizationServiceProvider you have conditions:
if ($laravelMajorVersion === 4) {
$langs = $app['path.base'].'/app/lang';
} elseif ($laravelMajorVersion >= 5 && $laravelMajorVersion < 9) {
$langs = $app['path.base'].'/resources/lang';
} elseif ($laravelMajorVersion >= 9) {
$langs = $app['path.base'].'/lang';
}
I use Laravel 11 and $laravelMajorVersion = 11, and when you are in this elseif ($laravelMajorVersion >= 5 && $laravelMajorVersion < 9) condition is true and try to read from wrong directory, please add condition >= 5 && < 9
The text was updated successfully, but these errors were encountered: