zend 语言环境与 url 路由

发布于 2024-10-01 18:36:48 字数 740 浏览 0 评论 0 原文

有没有一种简单的方法可以在 URL 中使用 zend 路由和区域设置来强制加载特定区域设置?

例如 - http://domain.com/en-US/controller1/action

所以language-Region 应该为所有 URL 调用添加前缀,并且只在引导程序中设置区域设置,但让 MVC 路由的其余部分正常工作。

理想情况下,它可以检测 URL 中是否没有语言区域,并尝试从浏览器自动检测。

例如 - http://domain.com/ (如果未找到语言环境 - 默认为 en-US/index)

我我看过一些关于自定义用户虚荣网址等路由的文章。例如 - http://domain.com/username (路由到 http://domain.com/user/load/username)

对我来说,它似乎应该与此类似,但我想知道是否有更优雅的东西?

谢谢,

安德烈

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

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

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

发布评论

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

评论(1

楠木可依 2024-10-08 18:36:48

我不想复制所有源代码,所以请查看

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

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