zend locale with url routing

我与影子孤独终老i 提交于 2019-12-22 18:30:19

问题


Is there a simple way of using zend routes and locales in the URL to force the loading of a particular locale?

e.g. - http://domain.com/en-US/controller1/action

So the language-Region should prefix all URL calls and just set the locale in the bootstrap but let the rest of the MVC routing work as normal.

ideally it could detect if no language-Region is in the URL and attempt to autodetect from the browser.

e.g. - http://domain.com/ (if no locale is found - defaults to en-US/index)

I've seen some articles on routes for things like custom user vanity urls. e.g. - http://domain.com/username (routes to http://domain.com/user/load/username)

To me it seems like it should be similar to this, but I was wondering if there's something more elegant?

Thanks,

Andre


回答1:


I dont want to copy over all the sourcecode, so have a look at

  • Zend Framework Best Practices – Part 2: I18n and
  • Chaining language with default route


来源:https://stackoverflow.com/questions/4137391/zend-locale-with-url-routing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!