Last active
January 31, 2016 14:19
-
-
Save zgabievi/c0f3efa153044f67e84c to your computer and use it in GitHub Desktop.
Localization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return [ | |
'locale' => 'en', | |
'locales' => [ | |
'en' => 'English', | |
'ka' => 'Georgian', | |
'ru' => 'Russian', | |
], | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Localization</title> | |
</head> | |
<body> | |
<h3>Locale: </h3> - {{ config('app.locales')[app()->getLocale()] }} | |
<ul> | |
@foreach (config('app.locales') as $locale => $language) | |
<li> | |
<a href="{{ route('locale.switch', $locale) }}">{{$language}}</a> | |
</li> | |
@endforeach | |
</ul> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::group(['middleware' => 'web'], function () { | |
Route::get('locale/{locale}', function ($locale) { | |
app()->setLocale($locale); | |
return redirect()->back(); | |
})->name('locale.switch'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment