6. View web pages in different locale at design-time and run-time
During developing an internationalized application, sometimes it is necessary
to view the JSP pages in the different languages to fix the localization and
web design issues related to internationalization.
Workshop's JSF support includes design
time support for localization resource bundles.
6.1. Configure the application for French
Open the JSF configuration file faces-config.xml.
Locate the <application> element
specifying the resource bundle and default locale for the application.
In the <locale-config> element add
a <supported-locale> element for the
French locale as shown below in bold
text.
You need to create the properties
file with key-value pairs for French
language support. You can import the file application_fr_FR.properties
from the folder workshop-JSF-tutorial/web/Resources
to the resources package.
Close the Eclipse IDE and start it again.
6.2. Localize the view at design time
Open register.jsp
In the Eclipse main menu bar select Text > Resource Locale.
The Resource Locale dialog is displayed, allowing you to
select configured locales for the web application.
Select the French (France)
locale and click OK.
Reset the Resource Locale to English
language.
6.3. Localize the view at design time [Optional]
The locale-config
element in faces-config.xml lists the
default locale and the other supported locales. The locale-config element
enables
the system to find the correct locale based on the browser's language
settings. In register.jsp page we will
manually set the French locale to
override these settings.
Open register.jsp
and write following lines of code after the tag libraries definitions
and before the <f:loadBundle>
tag.