How will Language Localization work in Laravel 9? New methods added

Laravel Localization is the language switch feature supported by Laravel. The lang directory, which is used for Laravel Localization used to be placed in resources/lang directory is now located in the root project directory (lang). Therefore, Laravel 9 has a different location for the lang directory. This is the main reason why localization is not working in Laravel 9, live server.

So, to avoid the conflict and stay intact with new upgrades, you may move your lang directory to Laravel root from the resources directory. This will make your languages files accessible from the new location and work properly as expected.

Note This applies only for users working with Laravel 9. As this Language Localization upgrade is only for Laravel 9. Laravel 8 still works on the old directory structure. So, to avoid further problems or errors you should not add this in Laravel 8 or other older versions.

So, after your remove the resources/lang directory in Laravel 9 applications, it will work as expected.

Moreover, you can hardcode your lang path using the useLangPath method in your AppServiceProvider‘s boot method. As shown below.

public function boot()

    // or app()->useLangPath(app()->basePath('lang'));

This will help you know the base path of the lang directory and confirm if you are using the right folder structure.

Leave a Comment