java - How to implement i18n(Subdirectories with gTLDs) in Spring Framework? -


i'm working on web application uses spring framework, spring (mvc), spring security, etc... spring documentation shows internationalization adding parameter in url, (e.g. http://myexample.com?lang=fr) have read article google "multi-regional , multilingual sites" states practice not recommended.

so decided implement way:

http://myexample.com/ -> default locale (en)

http://myexample.com/es/ -> locale es

http://myexample.com/fr/ -> locale fr

my question is: best way implement i18n (subdirectories gtlds) in spring framework? ideas, articles, examples welcome.

  <!-- defines interceptors locale change , theme change before request goes dispatcherservlet further operation. -->        <mvc:interceptors>         <ref bean="localechangeinterceptor"/>         <ref bean="themechangeinterceptor" />         <!-- <ref bean="conversionserviceexposinginterceptor"/> -->         </mvc:interceptors>      <!-- interceptor change in locale --> <bean id="localechangeinterceptor" class="org.springframework.web.servlet.i18n.localechangeinterceptor"> <property name="paramname" value="language"/> </bean>      <!-- localeresolver configuration internationalization. here cookie resolver used. stores , reads locale value cookie. --> <bean id="localeresolver" class="org.springframework.web.servlet.i18n.cookielocaleresolver"> <property name="defaultlocale" value="1"/> <property name="cookiepath" value="/webportal/" /> <property name="cookiename" value="locale"/> <property name="cookiemaxage" value="86400"/> <property name="cookiehttponly" value="true"/> <property name="cookiesecure" value="true"/> </bean>      <!-- provides list of base location localized property files. default encoding must utf-8 support multilingual text. -->     <bean id="messagesource" class="org.springframework.context.support.reloadableresourcebundlemessagesource">     <property name="basenames">         <list>         <value>/web-inf/i18n/labels</value>         <value>/web-inf/i18n/messages</value>         <value>/web-inf/i18n/mailbox</value>         <value>/project</value>         </list>     </property>     <property name="defaultencoding" value="utf-8"/>     </bean> 

here code achieve internationalization need add lines of code dispatcher-servlet.xml file , make changes according requirnments

hope reply guide ...


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -