bastienbot / laravel-set-lang by bastienbot

Package to detect and set languages easily for Laravel
388
0
2
Package Data
Maintainer Username: bastienbot
Maintainer Contact: bastien@eundigital.com (Bastien Botella)
Package Create Date: 2017-01-08
Package Last Update: 2017-01-09
Home Page:
Language: PHP
License: Unknown
Last Refreshed: 2024-11-23 03:18:21
Package Statistics
Total Downloads: 388
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Laravel set Lang

Infos

This package is only compatible with Laravel 5.1+ This package has two purposes :

  • Setting by default the language to the client browser language. Fallback language is english
  • Providing routes and a service provider to set the user's language choice in a cookie and retrieve it on load

Usage

  • Go to you Laravel project folder in your favorite terminal
  • Execute : composer require bastienbot/laravel-set-lang dev-master
  • Add the following line to the config/app.php :
'providers' => [
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        Illuminate\Bus\BusServiceProvider::class,
        ...
        ...
        ...
        Bastienbot\LaravelSetLang\LangServiceProvider::class,
  • Now you just need to create the links in HTML in your view(s), the anchors being : /lang/{lang}. {lang} should be a string, ex : en, fr, etc...