New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

marciojc/language-switch

A Laravel Package to switch language
13 1
Install
composer require marciojc/language-switch
Latest Version:1.0.0
Laravel:5
License:MIT
Last Updated:May 1, 2017
Links: GitHub  ·  Packagist
Maintainer: marciojc

Language Switch

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'
]);

Related Packages

vluzrmos/language-detector

Detect the language for your application using browser preferences, subdomains o...

590,683 109
swayok/laravel-language-detector

Detect the language for your application using browser preferences, subdomains o...

859 0
klisl/laravel-locale

Creating a multilanguage for the site Laravel-5

984 18
illuminate3/kotoba

Baseline language files for Laravel 5

719 0
illuminate3/lingos

Baseline language files for Laravel4

150 5

Version History

Version Released Laravel License
1.0.0 5.4.* MIT