Package Data | |
---|---|
Maintainer Username: | exolnet |
Maintainer Contact: | adeschambeault@exolnet.com (Alexandre D'Eschambeault) |
Package Create Date: | 2018-07-06 |
Package Last Update: | 2025-01-09 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-01-14 03:04:07 |
Package Statistics | |
---|---|
Total Downloads: | 11,113 |
Monthly Downloads: | 339 |
Daily Downloads: | 19 |
Total Stars: | 4 |
Total Watchers: | 5 |
Total Forks: | 0 |
Total Open Issues: | 5 |
Library to manage Laravel translations
Require this package with composer:
composer require exolnet/laravel-translation
In Laravel 5.5, the service provider and facade will automatically get registered. For older versions of the framework, follow the steps below:
Register the service provider in config/app.php
'providers' => [
// [...]
Exolnet\Translation\TranslationServiceProvider::class,
],
To make sure the routing system is using the one supporting the translation you must edit your app/Http/Kernel.php
to add the usage of the custom user dispatcher
use \Exolnet\Translation\Traits\CustomRouterDispatcher;
Now you're ready to start using the translation in your application.
In order to edit the default configuration (where for e.g. you can find available_locales
) for this package you may execute:
php artisan vendor:publish --provider="Exolnet\Translation\TranslationServiceProvider"
After that, config/translation.php
will be created. Inside this file you will find all the fields that can be edited in this package.
Exolnet Translation uses the URL given for the request. In order to achieve this purpose, a route group should be added into the routes/web.php
file. It will filter all pages that must be localized.
// routes/web.php
Route::groupLocales(function () {
Route::get('/', ['as' => 'home', 'uses' => 'HomeController@index']);
});
Once this route group is added to the routes file, a user can access all locales added into available_locales
. For example, a user can now access two different locales, using the following addresses:
http://url-to-laravel/en
http://url-to-laravel/fr
If you when to remove the locale prefix on the base locale you need to set the $avoidPrefixOnBaseLocale
to true
when defining the groupLocale
// routes/web.php
Route::groupLocales(function () {
Route::get('/', ['as' => 'home', 'uses' => 'HomeController@index']);
}, null, true);
To run the phpUnit tests, please use:
composer test
Please see CONTRIBUTING and CODE OF CONDUCT for details.
If you discover any security related issues, please email security@exolnet.com instead of using the issue tracker.
This code is licensed under the MIT license. Please see the license file for more information.