0

我想关闭在路由中禁用 i18n 的操作的语言切换器。我不想在任何地方对操作标识符进行硬编码,而是想获取有关当前模板/操作的 i18n 状态的信息。

/**
 * @Route("/path", name="route_name", options={"i18n" = false})
 * @Template("someAppBundle:Frontend/Home:something.html.twig")
 */
public function somethingAction()
{
    //How to check here if i18n is switch off?
    //How to check it directly in twig template?
    return array();
}
4

1 回答 1

2

您可以通过以下方式访问路线选项

$request->attributes->get('i18n')

或(在树枝中):

app.request.attributes.get('i18n')
于 2013-07-05T11:07:17.660 回答