【发布时间】:2017-02-21 12:20:36
【问题描述】:
我有一个五种语言的网站,每个页面的所有 URL 都翻译成每种语言,我将使用 Laravel 5.3 对其进行更新。
我已按照this 教程将以下多语言语言环境添加到我的项目中:
'locales' => ['de' => 'German', 'en' => 'English', 'fr' => 'French', 'it' => 'Italian', 'es' => 'Spanish']
这可能是web.php 文件中Contact Us 页面路由的示例:
Route::get('/kontakt', 'ContactController@index');
Route::get('/contact', 'ContactController@index');
Route::get('/contactez', 'ContactController@index');
Route::get('/contattaci', 'ContactController@index');
Route::get('/contacto', 'ContactController@index');
但如果我在浏览器中输入:
http://localhost/myproject/en/contattaci 或 http://localhost/myproject/en/kontakt
我可以访问“联系人”视图,这不应该发生,应该使用 en 区域设置 contact:/en/contact 和 contattaci 与意大利语 (/it/contattaci) 和 kontakt 与德语 (/de/kontakt) 等。
有人知道为什么会发生这种情况,或者哪种方法是创建不同翻译路线的正确方法?
【问题讨论】:
-
看看here
-
@Moppo 我很久以前就看过那个帖子,但对我没有用。但我试图再次遵循它,并且工作! :) 我想要
de前缀作为我的默认语言环境,所以我也将它添加到alt_langs数组中,但我现在需要的是重定向到/de,当只输入/时。我怎样才能做到这一点?
标签: php laravel routes multilingual