1

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!

4

2 回答 2

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"

它就像一个魅力!

于 2010-06-26T09:16:45.823 回答
0

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

Zend_Controller_Router_Route::setDefaultTranslator($translator);

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

于 2010-06-24T15:46:34.313 回答