Java Reference
In-Depth Information
zh (Chinese). The default locale, en (English), which is specified in the faces-con-
fig.xml file, uses the resource bundle with the base name, messages.properties .
For more details on internationalization and localization in the Java platform, see ( ht-
tp://docs.oracle.com/javase/tutorial/i18n/index.html ).
Providing Localized Messages and Labels
Messages and labels should be tailored according to the conventions of a user's language
and region. There are two approaches to providing localized messages and labels in a web
application:
• Provide a version of the web page in each of the target locales and have a controller
servlet dispatch the request to the appropriate page depending on the requested loc-
ale. This approach is useful if large amounts of data on a page or an entire web
application need to be internationalized.
• Isolate any locale-sensitive data on a page into resource bundles, and access the
data so that the corresponding translated message is fetched automatically and in-
serted into the page. Thus, instead of creating strings directly in your code, you
create a resource bundle that contains translations and read the translations from
that bundle using the corresponding key.
The Duke's Tutoring application follows the second approach. Here are a few lines from
the default resource bundle messages . properties :
Click here to view code image
nav.main=Main page
nav.status=View status
nav.current_session=View current tutoring session
nav.park=View students at the park
nav.admin=Administration
admin.nav.main=Administration main page
admin.nav.create_student=Create new student
admin.nav.edit_student=Edit student
admin.nav.create_guardian=Create new guardian
admin.nav.edit_guardian=Edit guardian
admin.nav.create_address=Create new address
admin.nav.edit_address=Edit address
admin.nav.activate_student=Activate student
Search WWH ::




Custom Search