8 Replies Latest reply on Oct 29, 2007 12:19 PM by Adrian Mitev

    Internationalization in RichFaces

    Steve Whatmore Newbie

      Good afternoon,

      Can anyone point me at a good RichFaces example application that includes internationalization.

      Alternatively, if you could highlight the proper approach / best practices (sample code) for I18N'ing a RichFaces application that would be appreciated as well.

      Thanks in advance.

      Whatty

        • 1. Re: Internationalization in RichFaces
          Tomislav Jakopec Novice

          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
            Tomislav Jakopec Novice

            forgot
            in WEB-INF/classes should be properties files

            example

            messages_en.properties
            messages_hr.properties
            


            and that files look like this

            messages_en.properties
            autorizacija.autorizacija = Authorization
            autorizacija.autoriziraj = Authorization
            autorizacija.dobrodosli = Welcome!
            autorizacija.jezik = Language
            autorizacija.lozinka = Password
            autorizacija.operater = Operater
            


            messages_hr.properties
            autorizacija.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
              Steve Whatmore Newbie

              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
                Steve Whatmore Newbie

                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
                  Igor Shabalov Apprentice

                  Yes, that is correct approach.

                  • 7. Re: Internationalization in RichFaces
                    Brian Parkinson Newbie

                    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
                      Adrian Mitev Master

                      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()