Announcement Announcement Module
Collapse
No announcement yet.
Migration to 2.8.0 led to trouble with properties files and i18n Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Migration to 2.8.0 led to trouble with properties files and i18n

    Hello all !


    I migrated to 2.8.0 yesterday morning, I converted my project as I was asked to (if no, my project wasn't able to compile anymore), and now, I have this trouble :

    my program is not able to make the key-value relationship anymore !

    I tried two ways to manage i18n :
    .1) the first one was working very fine until I updated to 2.8.0 :
    • in applicationContext.xml :
      Code:
          <bean class="org.springframework.context.support.ResourceBundleMessageSource" id="messageSource">
    Code:
    <property name="basenames">
                <list>
                    <value>WEB-INF/i18n/messages</value>
                    <value>WEB-INF/i18n/application</value>
                    <value>WEB-INF/i18n/businessMessages</value>
                </list>
            </property>
        </bean>
    • in webmvc-config.xml :
    Code:
    <bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" id="messageSource" p:basenames="WEB-INF/i18n/messages,WEB-INF/i18n/application,WEB-INF/i18n/businessMessages" p:fallbackToSystemLocale="false" />
    I know this may be redondant ... but it worked well untill yesterday. I tried to remove either one or the other but the problem is not solved.
    • I have an application context manager class :
      Code:
       public class ApplicationContextManager implements ApplicationContextAware {
       private static ApplicationContext context;
       public void setApplicationContext(ApplicationContext ctx)
         throws BeansException {
        context = ctx;
       }
       
       public static ApplicationContext getApplicationContext() {
        return context;
       }
       
      }
    • and an I18nManager that just define some easy-to-remember functions :
      Code:
       public class I18nManager {
       public static Locale getLocale() {
        return LocaleContextHolder.getLocale();
       }
       public static String getMessage(String key, Object[] parameters) {
        return ApplicationContextManager.getApplicationContext().getMessage(
          key, parameters, LocaleContextHolder.getLocale());
       }
       (...)  
      }
    All this was working fine, when I wanted to print a message into the expected language, I just had to do :
    Code:
    I18nManager.getMessage("my_key");
    As this doesn't work anymore since going to 2.8.0, I tried this :

    .2)
    Code:
    import org.springframework.context.i18n.LocaleContextHolder;
     
    public class maClass {
    
     @Autowired
     private MessageSource messageSource;
     
    protected void maMethode() {
    System.out.println(messageSource.getMessage("ma_cle", null, LocaleContextHolder.getLocale())); }
    
    }
    But this doesn't work too

    I lost 2 days of work arround this ... so please, if anyone can help : thank you !
    Last edited by Cedric.Vidrequin; Oct 20th, 2011, 10:58 AM.

  • #2
    what I forgot to say is that
    - all the i18n files (devided into 3 types of properties files : messages*.properties, application*.properties and businessMessages*.properties) are stored into WEB-INF/i18n
    - the first UI (login page) is well printed and some label ARE well translated, using thoses i18n files ! That means the system is able to translate the keys into the JSPX files but it is not able to find the blabla*.properties files into java classes !

    Any idea why please ???


    EDIT : as I debug the getMessage() method, I see that in RessourceBundleMessageSource.class, in protected ResourceBundle getResourceBundle(String basename, Locale locale) : the synchronized this.cachedResourceBundles is empty ! That is why the program is not able to find the key-value pairs.
    Does anyone knows why it is not able to find the properties files ???
    Last edited by Cedric.Vidrequin; Oct 20th, 2011, 10:40 AM.

    Comment


    • #3
      Hey Cedric!

      Did you take a look at the deployed files in the server to see if the property files got deployed?

      -Martin

      Comment


      • #4
        Hello Martin,


        sure I did The WEB-INF/i18n is at the expected place into the war file.

        It seems that it is a configuration problem and that the application is looking for the properties files in a wrong place ... but I can't understand why

        Comment


        • #5
          Hey Cedric!

          Don't know the reason either out of the box. If the deployed web app looks okay, it doesn't seem to be much related to the tooling. Nevertheless your comment about the migration to STS 2.8.0 makes me think about this twice. Maybe someone from the web or tc server forum can help? Would you like to ask there as well?
          Sorry for not being more helpful here...

          -Martin

          Comment

          Working...
          X