简体   繁体   English

如何禁用特定 symfony 路由的翻译?

[英]How to disable translation for a specific symfony route?

I am working on a internationalized symfony app where the locale for a webpage is in the url (eg : /en/myaccount and /fr/moncompte ).我正在开发一个国际化的 symfony 应用程序,其中网页的语言环境在 url 中(例如: /en/myaccount/fr/moncompte )。

What I would like to have is a custom webpage where I can see the page not translated, with he translation keys.我想要的是一个自定义网页,在那里我可以看到未翻译的页面,以及翻译键。 This behaviour should not change the behavior for the localized pages.此行为不应更改本地化页面的行为。

I have tried to add a locale with no translation file.我试图添加一个没有翻译文件的语言环境。 However the website fallback to the default locale which prevents seeing translation keys.然而,网站回退到默认语言环境,这会阻止看到翻译键。 Is there a way to disable localization (or fallback for a specific locale ? Is it possible to use a custom url which is not associated with a locale in the routing ?有没有办法禁用本地化(或特定语言环境的回退?是否可以使用与路由中的语言环境无关的自定义 URL?

Thank you !谢谢 !

I suggest you use the route with options={"i18n":"false"} then in the path you make locale like extensions you get something like this我建议你使用带有 options={"i18n":"false"} 的路由,然后在你制作语言环境的路径中,你会得到类似这样的扩展

/**
 *@Route("/{prefix}/moncompte", methods={"GET"}, options={"i18n":"false"}, requirements={"prefix"="fr|en|ar"})
*/

是的,您可以,在路由失败时使用 else(“未找到路由”)然后包含此页面而不是重定向到 404 页面。

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

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