我开发了一个多语言Web应用程序,一切正常。但是当我使用404页面时,本地化无法正常运行,只能看到默认语言(en)。
我开发了用于设置语言环境的中间件,并将其添加到内核中。我使用路由在会话中加入语言环境。但是当我调用404页面时,语言环境没有改变,我发现此页面从app / config.php读取语言环境
这是我的中间件和路由:
var genericType = typeof(TableQuery<>);
Type[] itemTypes = { Type.GetType("MyNamespace.Foo.Entities." + tableName) };
var concretType = genericType.MakeGenericType(itemTypes);
var query = Activator.CreateInstance(concretType);
请帮助我在<script type="text/javascript">
function calcTS() {
var g=document.getElementById('wt').value;
var ts=document.getElementById('Tspoon').value;
document.getElementById('Tspoon').value = g/4.2;
}
function calcG() {
var g=document.getElementById('wt').value;
var ts=document.getElementById('Tspoon').value;
document.getElementById('wt').value= ts*4.20;
}
中更改语言环境,或以其他方式在public function handle($request, Closure $next)
{
if(\Session::has('locale'))
{
\App::setlocale(\Session::get('locale'));
}
return $next($request);
}
Route::get('locale/{locale}', function ($locale) {
Session::put('locale', $locale);
return redirect()->back();
});
中更改语言环境。