Skip to content

Instantly share code, notes, and snippets.

@zgabievi
Last active January 31, 2016 14:19
Show Gist options
  • Save zgabievi/c0f3efa153044f67e84c to your computer and use it in GitHub Desktop.
Save zgabievi/c0f3efa153044f67e84c to your computer and use it in GitHub Desktop.
Localization
<?php
return [
'locale' => 'en',
'locales' => [
'en' => 'English',
'ka' => 'Georgian',
'ru' => 'Russian',
],
];
<!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>
<?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