Skip to content

Commit

Permalink
laravel 7
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Mar 7, 2020
1 parent d578be3 commit d82266a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Language switcher package for Laravel.
# Language switcher package for Laravel

[![Version](https://poser.pugx.org/akaunting/language/v/stable.svg)](https://github.com/akaunting/language/releases)
[![Downloads](https://poser.pugx.org/akaunting/language/d/total.svg)](https://github.com/akaunting/language)
[![StyleCI](https://styleci.io/repos/102290249/shield?style=flat&branch=master)](https://styleci.io/repos/102290249)
[![Quality](https://scrutinizer-ci.com/g/akaunting/language/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/akaunting/language)
[![License](https://poser.pugx.org/akaunting/language/license.svg)](LICENSE.md)
[![Version](https://img.shields.io/packagist/v/akaunting/language?label=release)](https://github.com/akaunting/language/releases)
![Downloads](https://img.shields.io/packagist/dt/akaunting/language)
[![StyleCI](https://github.styleci.io/repos/102290249/shield?style=flat&branch=master)](https://styleci.io/repos/102290249)
[![Quality](https://img.shields.io/scrutinizer/quality/g/akaunting/language?label=quality)](https://scrutinizer-ci.com/g/akaunting/language)
[![License](https://img.shields.io/github/license/akaunting/language)](LICENSE.md)

This package allows switching locale easily on Laravel projects. It's so simple to use, once it's installed, your App locale will change only by passing routes into SetLanguage middleware.

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": ">=5.6.4",
"laravel/framework": ">=5.4.0",
"consoletvs/identify": "1.*"
"jenssegers/agent": "2.6.*"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 4 additions & 2 deletions src/Middleware/SetLocale.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Akaunting\Language\Middleware;

use Closure;
use Unicodeveloper\Identify\Facades\IdentityFacade as Identify;
use Jenssegers\Agent\Agent;

class SetLocale
{
Expand Down Expand Up @@ -46,7 +46,9 @@ private function setLocale($locale)
public function setDefaultLocale()
{
if (config('language.auto')) {
$this->setLocale(Identify::lang()->getLanguage());
$agent = new Agent();

$this->setLocale(reset($agent->languages()));
} else {
$this->setLocale(config('app.locale'));
}
Expand Down
4 changes: 2 additions & 2 deletions src/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Unicodeveloper\Identify\IdentifyServiceProvider;
use Jenssegers\Agent\AgentServiceProvider;

class Provider extends ServiceProvider
{
Expand All @@ -30,7 +30,7 @@ public function boot(Router $router)

$router->aliasMiddleware('language', config('language.middleware'));

$this->app->register(IdentifyServiceProvider::class);
$this->app->register(AgentServiceProvider::class);

$this->app->singleton('language', function ($app) {
return new Language($app);
Expand Down

0 comments on commit d82266a

Please sign in to comment.