如何通过在Struts 2中单击在整个网站上应用i18n [英] How to apply i18n on whole website by a single click in Struts 2

查看:205
本文介绍了如何通过在Struts 2中单击在整个网站上应用i18n的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过单击将Struts 2国际化(i18n)应用于在网站的整个网页上将语言从英语更改为印地语?

Is it possible to apply Struts 2 Internationalization (i18n) for changing language from English to Hindi on whole web pages of website by single click?

如果可能的话,我该如何解决这个问题?

If it is possible then how can I resolve this problem?

推荐答案

该框架是国际化的.

您需要为每个语言环境资源包添加对应的 您通过struts标记显示的本地化消息.使用 text标记或getText()以在UI中检索消息.

You need to add the corresponding to each locale resource bundles for the localized messages that you display via the struts tags. Use text tag or getText() to retrieve a message in the UI.

浏览器语言与HTTP请求和框架一起传递 创建与浏览器设置相对应的语言环境.交换 通过将特殊参数request_locale传递给 i18n拦截器应该在您的堆栈上.

The browser language is passed with the HTTP request and framework create a locale corresponding to the browser settings. Switching locale performed via passing a special parameter request_locale to i18n interceptor that should be on your stack.

您还可以配置此拦截器以接受用户定义的 参数.

You can also configure this interceptor to accept user-defined parameters.

通常,对于用户会话,将持续切换到语言环境. 因此,您不必每次都在每个请求上传递参数,但是 如果需要,也可以支持这种情况.看看如何实现所有目标 以上使用本地化.

Normally switching to a locale persist for the session of the user. So, you don't have to pass a parameter each time on every request, but this case is also supported if needed. See how could you achieve all of the above using localization.

这篇关于如何通过在Struts 2中单击在整个网站上应用i18n的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆