Java中的本地化文本 [英] Localized text in Java

查看:237
本文介绍了Java中的本地化文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是在J2EE Web应用程序中显示本地化的文本消息。我知道J2EE为此提供了很好的支持。
我的问题是,存储本地化消息以供应用程序使用的做法是什么。如果我想显示日语/中文类型的消息,这些消息不像char设置的英语,我们如何将消息/文本放入属性文件或数据库表中。

My requirement is to display localized text messages in a J2EE web application. I know J2EE provides very good support for this. My question is what is the practice followed to have the localized messages stored to be used by the application. If I want to display Japanese / Chinese kind of messages which are not like English like char sets how do we get that messages/text into the properties files or Database tables.

推荐答案

资源束。基本思想是将所有文本本地化/国际化抽象出来并用源代码中的key替换,并且在运行时可以在语言环境之间切换。可以从例如资源包中选择不同的资源包实现。列出资源包或属性资源包。也可以编写自己的实现,比如数据库支持。

Resource Bundle. The basic idea is for all text to be localized/internationalized to be abstracted out and replaced by 'key' in source code, and at runtime you can switch among locales. Different implementation of resource bundles are available to be selected from, e.g. list resource bundle or properties resource bundle. It's also possible to write your own implementation, like database-backed.

Java国际化:使用ResourceBundles进行本地化是一个很好的快速起点。

Java Internationalization: Localization with ResourceBundles is a good and quick starting point.

有趣的是,尝试使用ResourceBundle的替代方案列出了资源包的一些缺点,并提供了替代方案。

Interestingly, Try alternatives to ResourceBundle lists some disadvantages of resource bundle and provides an alternative.

这篇关于Java中的本地化文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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