Java Reference
In-Depth Information
Figure 11.3: The Login page in French
Translating the Other Parts of the Application
displayed at the top:
The label for each menu item was hard-coded in the
Section
enumera-
tion; we now need to make it translatable. We can do that by removing
the text and replacing it with a resource bundle text key. We'll build
the key using a
section.
prefix followed by the name of the enumeration
constant:
public
enum Section {
MessageList(MessageListActionBean.
class
),
ContactList(ContactListActionBean.
class
),
Compose(MessageComposeActionBean.
class
);
private
String textKey, beanclass;
Section(Class<?
extends
ActionBean> beanclass) {
this
.textKey = "section." + name();
this
.beanclass = beanclass.getName();
}
public
String getTextKey() {
return
textKey; }
public
String getBeanclass() {
return
beanclass; }
}
The JSP that displays the menu is easily adapted by retrieving the text
from the resource bundle using the text key provided by each section.
Search WWH ::
Custom Search