问题
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