3 Replies Latest reply on Nov 27, 2009 2:02 PM by prati

    Wicket-Seam Internationalization best Practice

    mephisto

      Hi there,


      I'm really new to Wicket-seam and I can't get the wicket side localized. Seam localizes very fine with his messages Bunde.


      I think Wicket dosn't realize that the language has changed. I can't find any Information about how to configure wicket to use seams locale configuration.


      Does anyone know more about this?


      greets


      nico

        • 1. Re: Wicket-Seam Internationalization best Practice
          uwejanner.uwejanner.janner.at

          hi nico,


          as seam and wicket use completely different ways to handle i18n you have to couple them manually; you have to decide who is the master.



          e.g. you want wicket to let seam do the i18n work:




          getResourceSettings().addStringResourceLoader(new MyStringResourceLoader());
          
          public class MyStringResourceLoader implements
                    IStringResourceLoader {
          
               @Override
               public String loadStringResource(Component _component,
                    String _key) {
                    return getSeamResourceBundle().getString(_key);
               }
          
               @Override
               public String loadStringResource(Class _clazz, String _key,
                    Locale _locale, String _style) {
                    return getSeamResourceBundle().getString(_key);
               }
          
               private ResourceBundle getSeamResourceBundle() {
                    return ResourceBundle.getBundle(SeamResourceBundle.class.getName(), Session.get().getLocale());
               }
          }
          







          e.g., you want seam using the locale that wicket chose:
          overwrite seam's locale component with your implementation:




          @Scope(ScopeType.STATELESS)
          @Name("org.jboss.seam.core.locale")
          @Install(precedence=APPLICATION)
          @BypassInterceptors
          public class MyLocale extends org.jboss.seam.core.Locale{
             @Unwrap @Override
             public java.util.Locale getLocale(){
                  Locale locale = Locale.US;
                  Session session = Session.get();
                  if( session!=null ){
                     if( session.getLocale()!=null ){
                          locale = session.getLocale();
                     }
                  }
                  return locale;
             }
             
          }
          



          hope this helps,


          cheers uwe!

          • 2. Re: Wicket-Seam Internationalization best Practice
            prati

            Hi


            I just followed above steps created both classes,Now my wicket web page can read messagesen.properties,But when i change locale to France etc.It can't locate that.
            en
            GB is my default locale.
            Everytime it shows me in English.


            Thanks


            • 3. Re: Wicket-Seam Internationalization best Practice
              prati
              I am kind of struggling with thing ,Dont know where i am doing wrong ,I can set Locale to any other language using Session ,but its not able to read that corrosponding message.properties .I am using Wicket+Seam.

              Thanks in Advance!!