java - Internationalization using SPRING MVC -


below project-structure showing keep messages files:

  • web
  • java resources
  • src/main/resources
  • messages_en.properties
  • messages_fr.properties

bean configuration file define message source looks shown below:

<bean id="messagesource" class="org.springframework.context.support.resourcebundlemessagesource"> <property name="basenames"> <list> <value>messages_fr</value> </list> </property> </bean> 

i new concept of internationalization. don't know except if put .properies file inside tag picked , changes reflected. facing problem in dealing multiple .properties files. if have more 1 .properties file how should implement locale changes? how program know file take?

you should use :

<bean id="messagesource" class="org.springframework.context.support.resourcebundlemessagesource">     <property name="basenames">     <list>         <value>messages</value>     </list>     </property> </bean>enter code here 

spring use local specified when calling message bundle, don't have specify declaration of bundle.

note : think have name file : messages_fr_fr.properties or messages_en_en.properties.

edit :

you can specify local using :

messagesource.getmessage("messagekey", args, locale.france); 

to use messages_fr_fr

or

messagesource.getmessage("messagekey", args,localecontextholder.getlocale()); 

to use local selected user.

i hope may you


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -