【发布时间】:2014-07-25 03:21:13
【问题描述】:
我正在尝试翻译其中一些通过 Ajax 加载的视图,所以问题是,即使是语言环境,我也总是得到默认语言环境的文本,要清楚,这就是我的文件的外观:
app/config/app.php:
//...
'languages' => array('fr', 'en'),
'locale' => 'fr',
//...
routes.php
if(!Request::ajax()) {
// Set locale
$locale = Request::segment(1);
if(in_array($locale, Config::get('app.languages'))) {
App::setLocale($locale);
Session::put('locale', $locale);
} else {
$locale = null;
Session::put('locale', $locale);
}
$locale = Session::get('locale') or null;
}
// Group by locale
Route::group(
array( 'prefix' => $locale ), function () {
// Home controller
Route::get('/' . Config::get('app.lcoale'), array( 'uses' => 'HomeController@getIndex', 'as' => '/' ));
//...
ajax 路由不在以 locale 为前缀的组中:
Route::group(
array( 'prefix' => 'ajax', 'namespace' => 'Ajax', 'before' => 'ajax' ), function () {
//...
当我在发送 ajax 请求 Config::get('app.locale') 后检查当前语言环境时:它显示了正确的语言环境,但视图中呈现的文本是默认语言环境 (fr)。
这对你有意义吗?,请帮忙。
谢谢
【问题讨论】: