Localized text in Java

≡放荡痞女 提交于 2019-12-25 04:55:24

问题


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.


回答1:


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 Internationalization: Localization with ResourceBundles is a good and quick starting point.

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



来源:https://stackoverflow.com/questions/1997598/localized-text-in-java

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