Important: This solution has been merged into mcamara/laravel-localization
since version 1.3.11
.
This package is no longer required!
A cobbled together fix to allow caching routes per locale for mcamara's laravel localization.
See the github issue related to this fix in the original package.
This has been tested with laravel 5.1
through 5.6
.
Laravel | Package |
---|---|
5.1.x | 0.8.x |
5.2.x and up | 0.9.x |
Via Composer
$ composer require czim/laravel-localization-route-cache
If you don't use auto-discovery, add the service provider after mcamara's in your config/app.php
:
Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider::class,
Czim\LaravelLocalizationRouteCache\LaravelLocalizationServiceProvider::class,
In your App's RouteServiceProvider
, use the LoadsTranslatedCachedRoutes
trait:
class RouteServiceProvider extends ServiceProvider
{
use \Czim\LaravelLocalizationRouteCache\Traits\LoadsTranslatedCachedRoutes;
To cache your routes, use
php artisan route:trans:cache
instead of the normal route:cache
command.
To list the routes for a given locale, use
php artisan route:trans:list {locale}
# for instance:
php artisan route:trans:list en
To clear cached routes for all locales, use
php artisan route:trans:clear
Note that using route:clear
will also effectively unset the cache (at the minor cost of leaving some clutter in your bootstrap/cache directory).
The MIT License (MIT). Please see License File for more information.