Zend_Controller_Router_Route_Regex反向路由未翻译

时间:2010-06-24 12:13:21

标签: zend-framework zend-route zend-translate

这就是我的路线:

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路由器不会将其转换为特定语言,例如德语。 我有所有的翻译,除了Regex路线以外,所有路线的路线翻译工作正常吗?

有没有办法翻译呢?

非常感谢!

2 个答案:

答案 0 :(得分:3)

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

例如

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"

它就像一个魅力!

答案 1 :(得分:0)

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

Zend_Controller_Router_Route中:: setDefaultTranslator($译者);

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