简体   繁体   English

Symfony2如何检查i18n关闭当前操作(路由)的操作或模板?

[英]Symfony2 How to check in action or template that i18n is switch off for current action (route)?

I would like to switch off the language switcher for actions that has i18n disabled in route. 我想关闭语言切换器,以便在路由中禁用i18n。 I do not want to hardcode actions identifiers anywhere, instead I would like to get information about status of i18n for current template/action. 我不想在任何地方硬编码动作标识符,而是希望获得有关当前模板/动作的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();
}

you can access route options via 您可以通过访问路线选项

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

or (in twig): 或(在树枝上):

app.request.attributes.get('i18n')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM