-
1. Re: Internationalization in RichFaces
tjakopec Sep 10, 2007 3:11 AM (in response to steven.whatmore)faces-config.xml
<locale-config> <default-locale>hr</default-locale> <supported-locale>hr</supported-locale> <supported-locale>en</supported-locale> </locale-config>
some jsp page<r:panelBarItem label="#{messages['zajednicke.akcija']}">
seam default locale selector<h:selectOneMenu value="#{localeSelector.localeString}" styleClass="zelenoTankiBorder"> <f:selectItems value="#{localeSelector.supportedLocales}" /> <a:support event="onchange" action="#{localeSelector.select}"> <t:updateActionListener value="#{localeSelector.localeString}" property="#{oper.postavkeOperatera.jezik}" /> </a:support> </h:selectOneMenu>
-
2. Re: Internationalization in RichFaces
tjakopec Sep 10, 2007 3:22 AM (in response to steven.whatmore)forgot
in WEB-INF/classes should be properties files
examplemessages_en.properties messages_hr.properties
and that files look like this
messages_en.propertiesautorizacija.autorizacija = Authorization autorizacija.autoriziraj = Authorization autorizacija.dobrodosli = Welcome! autorizacija.jezik = Language autorizacija.lozinka = Password autorizacija.operater = Operater
messages_hr.propertiesautorizacija.autorizacija = Autorizacija autorizacija.autoriziraj = Autoriziraj autorizacija.dobrodosli = Dobrodo\u0161li! autorizacija.jezik = Jezik autorizacija.lozinka = Lozinka autorizacija.operater = Operater
P.S.
under Eclipse use ResourceBundle editor plugin -
3. Re: Internationalization in RichFaces
steven.whatmore Sep 10, 2007 9:57 AM (in response to steven.whatmore)Good morning,
First, thanks for the response.
I followed your instructions, placing a locale-config if the faces config file and created the corresponding message_XX.properties, however, it does not seem to be working.
Here is my FACES / JSP page<?xml version="1.0" encoding="ISO-8859-1" ?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" version="2.0"> <html xmlns="http://www.w3.org/1999/xhtml"> <ui:composition> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title> <h:outputText value="#{messages['administration.title']}"/> </title> </head> <body> <h1><h:outputText value="#{messages['administration.title']}"/></h1> <br/> <a href="administration/menu.jspx"><h:outputText value="#{messages['administration.menu']}"/></a> </body> </ui:composition> </html> </jsp:root>
which results in a blank page since the I18N messages are not being displayed properly.
Any thoughts?
Thanks in advance.
Whatty -
4. Re: Internationalization in RichFaces
steven.whatmore Sep 10, 2007 1:42 PM (in response to steven.whatmore)Good afternoon,
I added the following line<a4j:loadBundle basename="messages" var="msgs"/>
immediately following the<ui:composition>
tag and of course referenced the messages via<h:outputText value="#{msgs['administration.title']}"/>
which solved the problem.
Is this the correct way / "best practice" method in which to approach I18N?
Thanks in advance.
Whatty -
5. Re: Internationalization in RichFaces
ishabalov Sep 10, 2007 2:20 PM (in response to steven.whatmore)Yes, that is correct approach.
-
6. Re: Internationalization in RichFaces
steven.whatmore Sep 10, 2007 2:51 PM (in response to steven.whatmore)Thank you (all)
-
7. Re: Internationalization in RichFaces
parki Oct 29, 2007 12:07 PM (in response to steven.whatmore)Hi all -
Thanks for the above info - am now supporting internationalization in RichFaces using <a4j:loadBundle>
My web page contains:
<f:view locale="en>...
and if I change this to:
<f:view locale="fr">...
it all works.
My question is - how can I change this in code - I'd like to be able to change the locale "on the fly".
Any help is appreciated.
Thanks.
parki... -
8. Re: Internationalization in RichFaces
amitev Oct 29, 2007 12:19 PM (in response to steven.whatmore)You can change the locale on the fly but don't use <f:view locale="fr">. You can set the locale using
facesContext.getApplication().setDefaultLocale()