set current language with query string

This commit is contained in:
printempw 2017-01-14 18:51:07 +08:00
parent 10f86d4253
commit ba6ae737ca
10 changed files with 9 additions and 79 deletions

View File

@ -15,17 +15,4 @@ class HomeController extends Controller
return view('index')->with('user', $users->getCurrentUser());
}
public function locale($lang, Request $request)
{
if (Arr::exists(config('locales'), $lang)) {
Session::set('locale', $lang);
}
if (isset($_SERVER['HTTP_REFERER'])) {
return redirect('/')->setTargetUrl($_SERVER['HTTP_REFERER'])->withCookie('locale', $lang);
} else {
return redirect('/')->withCookie('locale', $lang);
}
}
}

View File

@ -16,15 +16,6 @@ use App\Exceptions\PrettyPageException;
class SetupController extends Controller
{
public function __construct(Request $request)
{
if ($locale = $request->input('lang')) {
cookie()->queue('locale', $locale);
session(['locale' => $locale]);
app()->setLocale($locale);
}
}
public function welcome()
{
// already installed

View File

@ -39,60 +39,8 @@ return [
'serializer' => 'League\Fractal\Serializer\DataArraySerializer',
],
/**
* DataTables script view template.
*/
'script_template' => 'datatables::script',
/**
* DataTables internal index id response column name.
*/
'index_column' => 'DT_Row_Index',
/**
* Namespaces used by the generator.
*/
'namespace' => [
/**
* Base namespace/directory to create the new file.
* This is appended on default Laravel namespace.
* Usage: php artisan datatables:make User
* Output: App\DataTables\UserDataTable
* With Model: App\User (default model)
* Export filename: users_timestamp
*/
'base' => 'DataTables',
/**
* Base namespace/directory where your model's are located.
* This is appended on default Laravel namespace.
* Usage: php artisan datatables:make Post --model
* Output: App\DataTables\PostDataTable
* With Model: App\Post
* Export filename: posts_timestamp
*/
'model' => '',
],
/**
* PDF generator to be used when converting the table to pdf.
* Available generators: excel, snappy
* Snappy package: barryvdh/laravel-snappy
* Excel package: maatwebsite/excel
*/
'pdf_generator' => 'excel',
/**
* Snappy PDF options.
*/
'snappy' => [
'options' => [
'no-outline' => true,
'margin-left' => '0',
'margin-right' => '0',
'margin-top' => '10mm',
'margin-bottom' => '10mm',
],
'orientation' => 'landscape',
],
];

View File

@ -7,5 +7,7 @@ general:
title: Error occurred
exception:
code: 'Error code: :code'
detail: 'Details: :msg'
message: |
Whoops, looks like something went wrong. (enable APP_DEBUG in .env to see details)

View File

@ -7,6 +7,8 @@ general:
title: 出现错误
exception:
code: 'Error code: :code'
detail: 错误码::code
message: |
如果您是访客,这说明网站程序出现了一些错误,请您稍后再试或联系站长。
如果您是站长,请开启 .env 中的 APP_DEBUG 以查看详细信息。

View File

@ -7,5 +7,5 @@
@include('setup.wizard.language')
</h1>
<p>{{ trans('errors.exception.message', ['msg' => $exception->getMessage() ?: trans('errors.http.msg-403')]) }}</p>
<p>{{ trans('errors.exception.detail', ['msg' => $exception->getMessage() ?: trans('errors.http.msg-403')]) }}</p>
@endsection

View File

@ -7,5 +7,5 @@
@include('setup.wizard.language')
</h1>
<p>{{ trans('errors.exception.message', ['msg' => $exception->getMessage() ?: trans('errors.http.msg-404')]) }}</p>
<p>{{ trans('errors.exception.detail', ['msg' => $exception->getMessage() ?: trans('errors.http.msg-404')]) }}</p>
@endsection

View File

@ -7,5 +7,5 @@
@include('setup.wizard.language')
</h1>
<p>{{ trans('errors.exception.message', ['msg' => $exception->getMessage() ?: trans('errors.http.msg-503')]) }}</p>
<p>{{ trans('errors.exception.detail', ['msg' => $exception->getMessage() ?: trans('errors.http.msg-503')]) }}</p>
@endsection

View File

@ -8,5 +8,5 @@
</h1>
<p>{{ trans('errors.exception.code', ['code' => $code]) }}</p>
<p>{!! trans('errors.exception.message', ['msg' => $message]) !!}</p>
<p>{!! trans('errors.exception.detail', ['msg' => $message]) !!}</p>
@endsection

View File

@ -7,7 +7,7 @@
</a>
<ul class="dropdown-menu" role="menu">
@foreach(config('locales') as $code => $langInfo)
<li class="locale"><a href="{{ url('/locale/'.$code) }}">{{ $langInfo['name'] }}</a></li>
<li class="locale"><a href="?lang={{ $code }}">{{ $langInfo['name'] }}</a></li>
@endforeach
</ul>
</li>