Package Data | |
---|---|
Maintainer Username: | marciojc |
Maintainer Contact: | marciojc@gmail.com (Márcio Coelho) |
Package Create Date: | 2017-04-29 |
Package Last Update: | 2017-05-01 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-26 03:00:04 |
Package Statistics | |
---|---|
Total Downloads: | 13 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
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'
]);