Skip to content

Commit

Permalink
FIX some error and ADD some improvements about languages
Browse files Browse the repository at this point in the history
  • Loading branch information
Webunion committed Nov 29, 2015
1 parent dc34f1e commit 4c891db
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
15 changes: 7 additions & 8 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@ public function index()
/**
* Change language.
*
* @param App\Jobs\ChangeLocaleCommand $changeLocaleCommand
* @param App\Jobs\ChangeLocaleCommand $changeLocale
* @param String $lang
* @return Response
*/
public function language( $lang = false,
ChangeLocale $changeLocale)
public function language(
ChangeLocale $changeLocale,
$lang)
{

$lang = in_array($lang, config('app.languages')) ? $lang : config('app.fallback_locale');
$changeLocale->lang = $lang;
$changeLocale->lang = in_array($lang, config('app.languages')) ? $lang : config('app.fallback_locale');

$this->dispatch($changeLocale);

return redirect()->back();
}

}
15 changes: 2 additions & 13 deletions app/Jobs/SetLocale.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@

class SetLocale extends Job implements SelfHandling
{
/**
* The availables languages.
*
* @array $languages
*/
protected $languages;

public function __construct(){
$this->languages = config('app.languages');
}

/**
* Execute the command.
*
Expand All @@ -30,9 +19,9 @@ public function handle()

if(!session()->has('locale'))
{
session()->put('locale', Request::getPreferredLanguage($this->languages));
session()->put('locale', Request::getPreferredLanguage( config('app.languages') );
}

app()->setLocale(session('locale'));
}
}
}
8 changes: 4 additions & 4 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@

/*
|--------------------------------------------------------------------------
| Application avaiable Languages
| Application available Languages
|--------------------------------------------------------------------------
|
| A list off avaiable languages defined from their ISO Language Codes codes, see more: http://www.w3schools.com/tags/ref_language_codes.asp.
| If the code isn't on the list, HomeController@language will set from fallback_locale value.
! To set new languages, pelase create an folder in /resources/lang/{ISO-CODE}, create a flag image in public/img/{ISO-CODE}-flang.png
| A list of available languages defined from their ISO Language Codes codes, see more: http://www.w3schools.com/tags/ref_language_codes.asp.
| If the code isn't in the list, HomeController@language is set from fallback_locale value.
! To set new language, pelase create a folder in /resources/lang/{ISO-CODE}, create a flag image in public/img/{ISO-CODE}-flang.png
! and at least, add the ISO code in languages array.
*/

Expand Down
3 changes: 3 additions & 0 deletions resources/assets/less/front/final.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
li.imgflag a { padding-left: 15px; }
@media screen and (min-width:768px) {
li.imgflag a { padding: 30px }
}
.nav > li.dropdown > a {
padding: 30px;
}

0 comments on commit 4c891db

Please sign in to comment.