This content has been marked as final.
Show 7 replies
-
1. Re: language resource bundle example
grdzeli_kaci Mar 20, 2007 8:05 AM (in response to grdzeli_kaci)and i forget i have added this fragment into my faces-config.xml file
<application> <locale-config> <default-locale>en</default-locale> <supported-locale>en</supported-locale> <supported-locale>ka</supported-locale> <supported-locale>de</supported-locale> <supported-locale>fr</supported-locale> </locale-config> <message-bundle>messages</message-bundle> </application>
-
2. Re: language resource bundle example
waynebagguley Mar 20, 2007 8:34 AM (in response to grdzeli_kaci)I don't have any of those configs and resource bundles work a treat.
In your <h:selectOneMenu> tag, you don't specify where it is supposed to store the selected value.
Here is the code taken from the Seam v1.2 documentation:<h:selectOneMenu value="#{localeSelector.language}"> <f:selectItem itemLabel="English" itemValue="en"/> <f:selectItem itemLabel="Deutsch" itemValue="de"/> <f:selectItem itemLabel="Francais" itemValue="fr"/> </h:selectOneMenu> <h:commandButton action="#{localeSelector.select}" value="#{messages['ChangeLanguage']}"/>
-
3. Re: language resource bundle example
grdzeli_kaci Mar 20, 2007 9:46 AM (in response to grdzeli_kaci)hi again,
i think that it is a bug in seam or jsf :(
i tryed this for three language : english (en) , german(de), francias (fr) and georegian(ka)
georgian is not working :(
code snippet<h:selectOneMenu value="#{localeSelector.language}"> <f:selectItem itemLabel="English" itemValue="en"/> <f:selectItem itemLabel="Deutsch" itemValue="de"/> <f:selectItem itemLabel="Francais" itemValue="fr"/> </h:selectOneMenu> <h:commandButton action="#{localeSelector.select}" value="#{messages['ChangeLanguage']}"/>
all works, but not ka(Georgian)
and one another question how i can use both login event and local selector event on one command button ? -
4. Re: language resource bundle example
avbentem Mar 20, 2007 9:50 AM (in response to grdzeli_kaci)"grdzeli_kaci" wrote:
i have added this fragment into my faces-config.xml file<locale-config> : <supported-locale>en</supported-locale> : </locale-config>
I think the supported-locale's are only needed when NOT explictely listing the available languages in the selectOneMenu. So, when using the list in faces-config.xml then your language selector could look like this:<h:selectOneMenu value="#{localeSelector.localeString}"> <f:selectItems value="#{localeSelector.supportedLocales}"/> </h:selectOneMenu> <h:commandButton action="#{localeSelector.select}" value="#{messages['ChangeLanguage']}"/>
(taken from the Seam documentation)
But this is not the cause of your problem; waynebagguley already explained what's wrong.
If you want to change the language without a button then see HOWTO: override ThemeSelector (valueChangeListener, cookie name). -
5. Re: language resource bundle example
waynebagguley Mar 20, 2007 10:29 AM (in response to grdzeli_kaci)The locale "ka(Georgian)" is not supported by Java.
-
6. Re: language resource bundle example
grdzeli_kaci Mar 21, 2007 2:01 AM (in response to grdzeli_kaci)"waynebagguley" wrote:
The locale "ka(Georgian)" is not supported by Java.
i think java supports ka(Georgian). I build example without seam, sample jsf project (or JSP project) and everithing works fine. here is my jsf example:
1. faces-config.xml<application> <locale-config> <default-locale>en</default-locale> <supported-locale>en</supported-locale> <supported-locale>ka</supported-locale> </locale-config> </application>
2. I created two Language property files:
LocalizationResources_en.properties
hello=HELLO WORLD EN!
LocalizationResources_ka.properties
hello=HELLO WORLD KA!
3. Login page:<h:form id="loginForm"> <h:panelGrid columns="2"> <h:outputText value="Language: " /> <h:selectOneMenu value="#{loginBean.language}"> <f:selectItem itemValue="ka" itemLabel="Georgian"/> <f:selectItem itemValue="en" itemLabel="English"/> </h:selectOneMenu> </h:panelGrid> <h:commandButton action="#{loginBean.doLogin}" value="Log In" id="gbutton" /> </h:form>
4. LoginBean.javaprivate String language; ................................ public String doLogin() { FacesContext facesContext = FacesContext.getCurrentInstance(); Locale locale = new Locale(language); facesContext.getViewRoot().setLocale(locale); return "navigation"; }
5. and at last result page after language choose:<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <f:loadBundle basename="LocalizationResources" var="bundle"/> <html> <head> <title></title> </head> <body> <f:view locale=""> <h:outputText value="#{bundle.hello}" /> </f:view> </body> </html>
all works fine, if i choose Georgian from select item componet on result page i saw georgian caption otherwise i saw english captions
i think that problem is in seam not java or jsf.
ooo yes avbentem, i forget i have this documentation and i did all what there is, all works fine, only georegian has problem.
my select item component looks like :<h:selectOneMenu value="#{localeSelector.localeString}" onchange="submit();" valueChangeListener="#{localeSelector.select}"> <f:selectItems value="#{localeSelector.supportedLocales}" /> </h:selectOneMenu>
and faces-config.xml i wrote above. -
7. Re: language resource bundle example
grdzeli_kaci Mar 21, 2007 2:27 AM (in response to grdzeli_kaci)i don't understand what happend but it already working
Georgian also working
sorry,
great thanks for your helpfull posts :)
waynebagguley avbentem