3.5 Internationalization
JSF in general provides very good support for internationalization. To support the proper local encoding of web pages, you just need to select the default encoding for the XHTML pages. A safe choice would be to use UTF-8 encoding:
<?xml version="1.0" encoding="UTF-8"?> ... ...
However, an issue in JSF is that it does not always submit the POST or GET data in the proper encoding format. To fix this, you can setup the following filter in components.xml to enforce UTF-8 encoding in HTTP requests.
<web:character-encoding-filter encoding="UTF-8" override-client="true" url-pattern="*.seam" />
Another important aspect of JSF is its ability to select different locales for localized strings in the UI. In Seam, you can define the locales supported by your application in components.xml.
<international:locale-config default-locale="en" supported-locales="en fr de"/>
Then, we can offer the user to select the correct locale for the UI via standard JSF mechanisms.
<h:selectOneMenu value="#{localeSelector.localeString}"> <f:selectItems value="#{localeSelector.supportedLocales}"/> </h:selectOneMenu> <h:commandButton action="#{localeSelector.select}" value="#{messages['ChangeLanguage']}"/>
The localized strings are defined in message bundles in the app.war/WEB-INF/classes directory. For example, the en (English) locale strings are defined in the messages_en.properties file.