Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Translated Route Caching Solution for Laravel Localization

License

Notifications You must be signed in to change notification settings

czim/laravel-localization-route-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Translated Route Caching Solution for Laravel Localization

Software License

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.

Version Compatibility

Laravel Package
5.1.x 0.8.x
5.2.x and up 0.9.x

Change log

View the change log.

Install

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;

Usage

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).

Credits

License

The MIT License (MIT). Please see License File for more information.