Getting localized strings
At this point, the LoginFormComponent can be internationalized. The next step is to pass the strings containing the captions in the correct language. Usually, the Locale and ResourceBundle standard Java classes are good enough to externalize localized messages. However, it is also a good idea to isolate string externalization logic into a separate class that allows clients to add resource bundles and get localized strings by name. Encapsulating this logic into a separate class allows you to change the underlying mechanism (for example, to read the messages from a database) and add features such as caching without affecting the rest of the application.
The following is an implementation of the Messages utility class ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access