Results 1 to 5 of 5

Thread: Migration to 2.8.0 led to trouble with properties files and i18n

Threaded View

  1. #1

    Unhappy 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 at 09:58 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •