1 2 Previous Next 29 Replies Latest reply on Oct 15, 2013 7:29 AM by pawo509

    Seam looses internationalization capabilities

    gadeyne.bram

      Hi,

       

      I'm using seam 2.2.2.Final with Richfaces 3.3.3.Final on JBoss AS 6.

       

      My application is translated into 2 languages (dutch and english).

       

      Sometimes ( at server startup or varying from  hours to days) the web application looses the translations. It then only displays the key's as labels and not the translations.

      Would anyone know what causes this?

      First I thought it could be caused by the character set used in dutch. I then converted the files to ascii with native2ascii.exe but this did not solve the problem.

      I'm using the default messages.properties files from seam. In my case these are messages_nl.properties and messages_en.properties. In JSF I use the EL-tags #{messages['key']}.

      My faces-config.xml file contains these settings:

      <?xml version="1.0" encoding="UTF-8"?>
      <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
      <application>
      <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
      <locale-config>
           <default-locale>nl</default-locale>
           <supported-locale>nl</supported-locale>
           <supported-locale>en</supported-locale>
           </locale-config>
      </application>
      </faces-config>

      In JSF I use it like this:

      <h:outputText value="#{messages['admin.scheduling.title']}" /> 

      In Code I use

      Messages.instance().get("admin.scheduling.title"); 

      Can I add some error logging somewhere to maybe find a log message indicating the problem?

        • 1. Re: Seam looses internationalization capabilities
          gebuh

          have you tried using the english locale?  Does it do the same thing?

          • 2. Re: Seam looses internationalization capabilities
            gadeyne.bram

            When it happens again I'll change the browsers locale to english en let you know if it found the english version.

            • 3. Re: Seam looses internationalization capabilities
              gadeyne.bram

              It just happened again. If I change the locale to english the problem persists.

              • 4. Re: Seam looses internationalization capabilities
                gadeyne.bram

                I still have this problem. What seam component should be responsible for this internationalisation? Maybe I could put a logger on it using a Debug, Fine of Finest log level?

                 

                Any ideas?

                • 5. Re: Seam looses internationalization capabilities
                  gebuh

                  Bram, can you duplicate this?  If so what do you do to make it happen?  I don't have any concrete ideas on what could be causing the problem, but I'm wondering is it related to your server load.

                  • 6. Re: Seam looses internationalization capabilities
                    gadeyne.bram

                    Hi Beth,

                     

                    We'll I'm not sure. I don't think server load could be the problem. Mostly there are only 6 concurrent users.

                     

                    Could some external program cause this?

                     

                    Our application is opened from another application that opens a IE browser as a tab in the program. I think its IE version 7. The problem never occured when I open it directly from IE or some other browsers. But when it is opened from this external program this somethimes hapens. I can however not reproduce it because I never know when it is goiing to hapen.

                     

                    I also know that this external program adds GET parameters to the URL. I don't think this would cause sutch a problem?

                     

                    Kind regards Bram

                    • 7. Re: Seam looses internationalization capabilities
                      gadeyne.bram

                      I'm still fasing this issue. Would anyone know how I could debug this? Maybe alter a logging setting or something? Does seam use an external package for the internationalisation? The logging for the org.jboss.seam package does not mention anything about internationalisation.

                      • 8. Re: Seam looses internationalization capabilities
                        manarh

                        Hey Bram,

                        why don't you use configuration in components.xml?

                         

                        For instance like this:

                        <international:locale-config default-locale="fr_CA" supported-locales="en fr_CA fr_FR"/>

                        • 9. Re: Seam looses internationalization capabilities
                          gadeyne.bram

                          It seems like I have used jdk6 dependencies where seam 2.2 only supports jdk5.

                           

                          I've received some feedback on the IRC channel. I'll try these things

                           

                          -Change jdk6 dependencies back to jdk5

                          -Change the  web_app version van 3.0 to 2.5

                          -Move back from AS 6 to AS 5

                           

                          I've also added a messages.properties file next to messages_nl and messages_en as a default properties file.

                          • 10. Re: Seam looses internationalization capabilities
                            mkouba

                            Hi Bram,

                             

                            if you get the keys instead of the values it means that there is no value for the given key and locale. In Seam2/JSF app the current locale is derived from JSF calculated value (HTTP Accept-Language header + supported locales...) and from cookie with name "org.jboss.seam.core.Locale" if it exists - see SeamViewHandler#calculateLocale() and LocaleSelector. So maybe the cookie send along with the request is a problem...

                             

                            There's not much logging in Seam i18n components however you can replace the original components and add your own logging.

                             

                            I would try something like this...

                            @Scope(ScopeType.STATELESS)
                            @BypassInterceptors
                            @Name("org.jboss.seam.international.messagesFactory")
                            @Install(precedence = DEPLOYMENT)
                            public class CustomMessages {
                            
                                protected Map createMap() {
                                    return new AbstractMap() {
                                        ...
                                        @Override
                                        public String get(Object key) {
                            
                                            if (key instanceof String) {
                                                String resourceKey = (String) key;
                                                String resource;
                            
                                                try {
                                                    resource = bundle.getString(resourceKey);
                                                } catch (MissingResourceException mre) {
                                                    // Log missing resource
                                                    logger.warn("Missing resource with key: "+mre.getKey+", locale: "+org.jboss.seam.core.Locale.instance());                        
                                                    return resourceKey;                     }                    return (resource == null) ? resourceKey : resource;                 } else {                    return null;                 }             }            ...     } }
                            • 11. Re: Seam looses internationalization capabilities
                              gadeyne.bram

                              Hi Martin,

                               

                              Thanks for this solution. I'll give it a try. The translations do work and are available but at some point they just disapear. It's like some process just stops.

                              • 12. Re: Seam looses internationalization capabilities
                                gadeyne.bram

                                I've tried

                                -pulling down the jdk version from 6 to 5

                                -using AS5 server in stead of AS6.

                                -downgrading the web_app and ejb versions to support jdk5.

                                 

                                This morning however the same issue occured on this new setting. Again without any notice in the log files.

                                • 13. Re: Seam looses internationalization capabilities
                                  gadeyne.bram

                                  Like Martin suggested I've added logging to a CustomMessages component. My CustomMessages extends the org.jboss.seam.international.Messages class.

                                   

                                  I've writen override methods for createMap and getMessages.

                                   

                                  Here I've added logging that checks the requested Locale and counts the messages in the Map generated by org.jboss.seam.international.Messages.

                                   

                                  When this problem occurs the count is only 72 while otherwise there are 497 entry's in the map.

                                   

                                  I've notices that the org.jboss.seam.international.Messages class uses the SeamResourceBundle class

                                   

                                  Those are probably 16 messages from org.hibernate.validator.DefaulValidatorMessages and 56 messages from javax.faces.messages.properties.

                                   

                                  Any ideas on what could go wrong?

                                  • 14. Re: Seam looses internationalization capabilities
                                    mkouba

                                    And I suppose the requested locale is correct, is it? Messages use SeamResourceBundle and in the end java.util.ResourceBundle is used (see ResourceLoader#loadBundle()). Maybe there is some classloading issue. What is the structure of your deployment? (EAR, WAR, etc.)

                                    1 2 Previous Next