แž‚แŸแž แž‘แŸ†แž–แŸแžš Business Insider แžŽแŸ‚แž“แžถแŸ†โ€‹แžŸแŸ€แžœแž—แŸ…โ€‹แž›แŸ’แžขโ€‹แž”แŸ†แž•แžปแž แŸฆ แž€แŸ’แž”แžถแž›โ€‹แžŸแž˜แŸ’แžšแžถแž”แŸ‹โ€‹แžแŸ‚โ€‹แž˜แžธแž“แžถโ€‹แžŠแŸ‚แž›โ€‹แžขแŸ’แž“แž€โ€‹แž‚แžฝแžšโ€‹แžแŸ‚โ€‹แžขแžถแž“โ€‹
แž‚េแž แž‘ំแž–័แžš Business Insider แžŽែแž“ាំ​แžŸៀแžœแž—ៅ​แž›្แžข​แž”ំแž•ុแž แŸฆ แž€្แž”ាแž›​แžŸแž˜្แžšាแž”់​แžែ​แž˜ីแž“ា​แžŠែแž›​แžข្แž“แž€​แž‚ួแžš​แžែ​แžขាแž“​

แŸก) แžŸៀแžœแž—ៅ How to Win Friends & Influence People แž“ិแž–แž“្แž’​แžŠោแž™​แž›ោแž€ Dale Carnegie แž្แžšូแžœ​แž”ាแž“​แž›แž€់​แžขแžŸ់​แž…្แžšើแž“​แž‡ាแž„​ แŸกแŸฅ แž›ាแž“​แž€្แž”ាแž› แž”ោះ​แž–ុแž˜្แž–​แžាំแž„​แž–ី​...

Read more »

แž‡แžฝแž” แžขแŸ’แž“แž€โ€‹แž›แžพแž€โ€‹แž‘แž„แŸ‹แž‡แžถแžแžทโ€‹แžแŸ’แž˜แŸ‚แžš โ€‹แž“แŸ…โ€‹ WTO
แž‡ួแž” แžข្แž“แž€​แž›ើแž€​แž‘แž„់แž‡ាแžិ​แž្แž˜ែแžš ​แž“ៅ​ WTO

แž‡ួแž” แžข្แž“แž€​แž›ើแž€​แž‘แž„់แž‡ាแžិ​แž្แž˜ែแžš ​แž“ៅ​ WTO 1 Jan, 2015 05:00 แž”ុแž‚្แž‚แž›แž‡ោแž‚แž‡័แž™ ,  แžšแžŸ់แž‡ីแžœិแž 8   Comment (s) แž្แž„ៃแž‘ីแž˜ួแž™แž“ៃแž†្แž“ាំแž្แž˜ី แž”ើแžขแž់แž‘ា...

Read more »

แŸงโ€‹แžƒแŸ’แž›แžถ โ€‹โ€‹โ€‹แž”แžปแž‚แŸ’แž‚แž›โ€‹แž‡แŸ„แž‚แž‡แŸแž™โ€‹แž“แžถแž“แžถโ€‹โ€‹แž˜แžทแž“โ€‹แžŠแŸ‚แž›โ€‹แž“แžทแž™แžถแž™โ€‹
แŸง​แžƒ្แž›ា ​​​แž”ុแž‚្แž‚แž›​แž‡ោแž‚แž‡័แž™​แž“ាแž“ា​​แž˜ិแž“​แžŠែแž›​แž“ិแž™ាแž™​

แŸง​แžƒ្แž›ា ​​​แž”ុแž‚្แž‚แž›​แž‡ោแž‚แž‡័แž™​แž“ាแž“ា​​แž˜ិแž“​แžŠែแž›​แž“ិแž™ាแž™​ 24 Feb, 2016 10:05 แž”ុแž‚្แž‚แž›แž‡ោแž‚แž‡័แž™ ,  แž”ុแž‚្แž‚แž›แž”แž…្แž…េแž€แžœិแž‘្แž™ា 0   Comment (s) ​แž—ាแž–​แž‡ោแž‚แž‡័...

Read more »

Hi there, I'm using JMeter to load test a web application that's using Spring Security (aka. Acegi) and I'm running into a str...

Read more »

Add bin and target to global svn ignore in Eclipse
Add bin and target to global svn ignore in Eclipse

This will keep you from committing bin and target directory files when you add projects to svn Click on  Window -> Preferences Sel...

Read more »

Change Heap memory
Change Heap memory

If you want to run many project in one time, you must configure tomcat heap memory. -XX:PermSize=256m -XX:MaxPermSize=256m

Read more »

1
2
3
4
5
6
<!-- Application Message Bundle -->
<bean id="messageSource"
  class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
  <property name="basename" value="classpath:messages/messages" />
  <property name="defaultEncoding" value="UTF-8"/>
</bean>
The configuration specifies that the message resource files should be named messages_xx.properties (xx is the shortcut of the locale), are stored in the messages folder in the classpath, and that the default encoding for the files is UTF-8.
messages classpath
Message resource files in classpath
Note: If the message resources files change often and you don’t want to restart the JVM, you should useorg.springframework.context.support.ReloadableResourceBundleMessageSource
Spring’s DispatcherServlet enables you to automatically resolve messages using the client’s locale. This is done with LocaleResolver objects. You can select between
  • an AcceptHeaderLocaleResolver, which inspects the accept-language header in the request that was sent by the client (e.g., a web browser). Usually this header field contains the locale of the client’s operating system.
  • CookieLocaleResolver,
  • and a SessionLocaleResolver, which allows you to retrieve locales from the session that might be associated with the user’s reques

CookieLocaleResolver

The CookieLocaleResolver made the most sense for Podcastpedia.org . It inspects a cookie namedpodcastpediaPreferredLanguage, that might exist on the client to see if a locale is specified:
If the cookie is not found, then the defaultLocale is set to American English. The cookieMaxAge (the maximum time a cookie will stay persistent on the client) is set to 604800 seconds (one month).

LocaleChangeInterceptor

The LocaleResolver is normally used in combination with the LocaleChangeInterceptor, which allows you to change of the current locale by using a defined parameter in the request (in this case the langparameter). So, for example, a request for the following URL,http://www.podcastpedia.org/categories?lang=de, will change the site language to German:


Access the Locale in Spring

If you need to access the current locale in Spring you can use theorg.springframework.context.i18n.LocaleContextHolder.LocaleContextHolder.getLocale(), which returns the Locale associated with the current thread, if any, or the system default Locale else. In the following code snippet you can see how I use this in the start page’s controller to display the newest and most popular podcasts based on the language selected:

Browser Caching optimization

If you have enabled browser caching, as specified for example in the post How To: Enable compression and leverage browser caching with Apache Server, make sure you set the expiring and cache controlfor the html pages to 0 seconds:
, so that changing the locale is effective immediately for the page – otherwise if you come back later to the same page, but without the locale parameter in the url, you would have the page displayed in the old locale, if the expiration time was not reached yet.
Well, that’s All Folks! If you would like to have Podcastpedia.org localized in your language, you can download the message resource file for English – messages_en.properties, and contact me at ama [AT] codingpedia DOT org – thanks
If you liked this, please show your support by helping us with Podcastpedia.org
We promise to only share high quality podcasts and episodes.
Internationalization & localization
Internationalization & localization

Spring 3 MVC: Internationalization & localization  Application Context Configuration Message Resource Files Normally in the Java...

Read more »
 
 
 
Top