marciojc / language-switch
A Laravel Package to switch language
1.0.0
2017-04-29 22:57 UTC
Requires
- browner12/helpers: ^1.0
- illuminate/support: 5.4.*
Requires (Dev)
- laravel/framework: ^5.4
- phpunit/phpunit: ^6.1
This package is not auto-updated.
Last update: 2024-11-21 07:27:01 UTC
README
Website & Documentation: https://github.com/marciojc/language-switch
After creating your new Laravel application you can include the LanguageSwitch package with the following command:
composer require marciojc/language-switch
Add the LanguageSwitch service provider to the config/app.php
file in the providers
array:
'providers' => [ // Laravel Framework Service Providers... //... // Package Service Providers marciojc\LanguageSwitch\LanguageSwitchServiceProvider::class, // ... // Application Service Providers // ... ],
Now, you can use LanguageSwitch, like this
<div class="language"> @if (App::getLocale() == 'pt') <a class="lang-link" href="{{getTranslationUrl('en')}}">{{ trans('common.en') }}</a> @else <a class="lang-link" href="{{getTranslationUrl('pt')}}">{{ trans('common.pt') }}</a> @endif </div>
When your route use some id or slug, you must say what model to use
Route::get(trans('routes.news') . '/{slug}' , [ 'as' => 'newsdetails', 'uses' => 'NewsController@details', 'model' => 'App\News' ]);