本地化路由和 URL 字符串

发布于 2024-12-27 18:06:57 字数 327 浏览 3 评论 0 原文

是否有一些常见的解决方案或最佳实践如何在 (java) Play! 中实现本地化 URL 字符串和路由!应用?

我们需要这样的路由:

/examples/demonstration

/esempi/dimostrazione

/przyklady/demonstracji

...(10多种语言)

自然所有URL指向控制器示例和操作演示

提前致谢!

Is there some common solution or best practice how to implement localized URL string and routes in (java) Play! application?

we need routes like this:

/examples/demonstration

/esempi/dimostrazione

/przyklady/demonstracji

...(10+ languages)

All URLs naturally pointing to controller Examples and action demonstration.

Thanks in advance!

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

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

发布评论

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

评论(1

烟─花易冷 2025-01-03 18:06:57

也许你可以做这样的事情:

对于英语:

%{ if (play.i18n.Lang.getLocale().getLanguage().equals("en")) { }%
GET     /add-new-post                Application.addNewPost
%{ } }%

对于荷兰语:

%{ if (play.i18n.Lang.getLocale().getLanguage().equals("nl")) { }%
GET     /voeg-nieuwe-commentaar      Application.addNewPost
%{ } }%

等等等等。

学分:http://playframework.wordpress.com/2011/07/15/hidden-features-of-the-play-framework-routes-file/

祝你好运

Perhaps you can do something like this:

For English:

%{ if (play.i18n.Lang.getLocale().getLanguage().equals("en")) { }%
GET     /add-new-post                Application.addNewPost
%{ } }%

For Dutch:

%{ if (play.i18n.Lang.getLocale().getLanguage().equals("nl")) { }%
GET     /voeg-nieuwe-commentaar      Application.addNewPost
%{ } }%

Etc etc..

Credits: http://playframework.wordpress.com/2011/07/15/hidden-features-of-the-play-framework-routes-file/

Good luck

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