Zend_Controller_Router_Route_Regex 反向路由未转换

发布于 2024-09-07 01:08:57 字数 664 浏览 12 评论 0原文

这就是我的路线的样子:

acc_long.type = Zend_Controller_Router_Route_Regex
acc_long.route = "@accommodation/([A-Za-z-]+)/([0-9A-Za-z-]+)-([0-9]+)"
acc_long.map.1 = 'location'
acc_long.map.2 = 'name'
acc_long.map.3 = 'id'
acc_long.defaults.controller    = "accommodation"
acc_long.defaults.action        = "index"
acc_long.defaults.module        = "default"
acc_long.defaults.location      = 'FALSE'
acc_long.defaults.name          = 'FALSE'
acc_long.defaults.id            = 'FALSE'
acc_long.reverse = "@accommodation/%s/%s-%d/"

但是 zend router 不会将其翻译成特定语言,例如德语。 我有所有可用的翻译,并且路线翻译在除正则表达式路线之外的所有路线中都工作正常?

有没有办法也翻译一下?

非常感谢!

This is how my route looks like:

acc_long.type = Zend_Controller_Router_Route_Regex
acc_long.route = "@accommodation/([A-Za-z-]+)/([0-9A-Za-z-]+)-([0-9]+)"
acc_long.map.1 = 'location'
acc_long.map.2 = 'name'
acc_long.map.3 = 'id'
acc_long.defaults.controller    = "accommodation"
acc_long.defaults.action        = "index"
acc_long.defaults.module        = "default"
acc_long.defaults.location      = 'FALSE'
acc_long.defaults.name          = 'FALSE'
acc_long.defaults.id            = 'FALSE'
acc_long.reverse = "@accommodation/%s/%s-%d/"

But zend router doesn't translate it into a specific language, to german for example.
I have all the translations available, and translation of routes is working fine in all routes except for Regex route?

Is there any way to translate it also?

Thank you very much!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光沙漏 2024-09-14 01:08:57

解决方案是使用链接,
所以路由的“静态”部分是一个单独的路由。

例如

language.type = Zend_Controller_Router_Route
language.route = ":lang/"
language.reqs.lang = "(en|de)"
language.defaults.lang = "de"
language.defaults.controller = "index"
language.defaults.module = "default"
language.defaults.action = "index"

acc_long.type = Zend_Controller_Router_Route_Regex
acc_long.route = "([A-Za-z-]+)/([0-9A-Za-z-]+)-([0-9]+)"
acc_long.map.1 = 'location'
acc_long.map.2 = 'name'
acc_long.map.3 = 'id'
acc_long.defaults.action        = "index"
acc_long.defaults.location      = 'FALSE'
acc_long.defaults.name          = 'FALSE'
acc_long.defaults.id            = 'FALSE'
acc_long.reverse = "%s/%s-%d/"

acc.type = Zend_Controller_Router_Route
acc.route = "@accommodation"
acc.defaults.controller    = "accommodation"
acc.defaults.action        = "index"
acc.defaults.module        = "default"

acc_long_chain.type = Zend_Controller_Router_Route_Chain
acc_long_chain.chain = "language, acc, acc_long"

,它就像一个魅力!

The solutiuon is to use chaining,
so the "static" part of the route is a separate route.

for example

language.type = Zend_Controller_Router_Route
language.route = ":lang/"
language.reqs.lang = "(en|de)"
language.defaults.lang = "de"
language.defaults.controller = "index"
language.defaults.module = "default"
language.defaults.action = "index"

acc_long.type = Zend_Controller_Router_Route_Regex
acc_long.route = "([A-Za-z-]+)/([0-9A-Za-z-]+)-([0-9]+)"
acc_long.map.1 = 'location'
acc_long.map.2 = 'name'
acc_long.map.3 = 'id'
acc_long.defaults.action        = "index"
acc_long.defaults.location      = 'FALSE'
acc_long.defaults.name          = 'FALSE'
acc_long.defaults.id            = 'FALSE'
acc_long.reverse = "%s/%s-%d/"

acc.type = Zend_Controller_Router_Route
acc.route = "@accommodation"
acc.defaults.controller    = "accommodation"
acc.defaults.action        = "index"
acc.defaults.module        = "default"

acc_long_chain.type = Zend_Controller_Router_Route_Chain
acc_long_chain.chain = "language, acc, acc_long"

And it works like a charm!

痴情换悲伤 2024-09-14 01:08:57

您是否尝试过设置默认翻译器?

Zend_Controller_Router_Route::setDefaultTranslator($translator);

http: //framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.standard.translated-segments

Have you tried setting the default translator?

Zend_Controller_Router_Route::setDefaultTranslator($translator);

http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.standard.translated-segments

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文