【发布时间】:2017-04-15 06:32:20
【问题描述】:
这是一个非常奇怪的情况。我的一些路线不想被翻译。我正在使用 Laravel mcamara/laravel-localization 包。
路由按照文档中的说明进行翻译。 在我的网站上,每个翻译都有一个标志来更改语言。通过将鼠标悬停在标志上,它只会更改语言,但不会翻译路线。奇怪的是,对于某些路线它有效,但对于某些路线无效,我无法找出逻辑是什么。
例如,我有一个用于显示文章的控制器。以下是路线:
Route::get(LaravelLocalization::transRoute('routes.artciles').'/{id}/{slug}.html', ['as' => 'strategy.show', 'uses' => 'ArticlesController@show']);
Route::get(LaravelLocalization::transRoute('routes.artciles').'/{category}.html', ['as' => 'strategy.category', 'uses' => 'ArticlesController@category']);
Route::get(LaravelLocalization::transRoute('routes.artciles').'.html', ['as' => 'strategy.index', 'uses' => 'ArticlesController@index']);
这里无法翻译路线?
通过悬停我只看到:
en/articles.html, de/articles.html 而不是 en/articles.html de/artikel.html。
【问题讨论】:
-
LaravelLocalization::transRoute('routes.artciles')中没有错字吗?你不是说'routes.articles'吗? -
很遗憾没有。在 lang/routes.php 中也是同样的错字:(