គេហទំព័រ Business Insider ណែនាំ​សៀវភៅ​ល្អ​បំផុត ៦ ក្បាល​សម្រាប់​ខែ​មីនា​ដែល​អ្នក​គួរ​តែ​អាន​

១) សៀវភៅ How to Win Friends & Influence People និពន្ធ​ដោយ​លោក Dale Carnegie ត្រូវ​បាន​លក់​អស់​ច្រើន​ជាង​ ១៥ លាន​ក្បាល បោះ​ពុម្ព​តាំង​ពី​ឆ្នាំ ១៩៣៦ រៀបរាប់​ពី​គំនិត​រាប់​លាន​របស់​បុគ្គល​ដែល​ជោគជ័យ​ក្នុ…

Read more »
26 Mar 2016

ជួប អ្នក​លើក​ទង់ជាតិ​ខ្មែរ ​នៅ​ WTO

ជួប អ្នក​លើក​ទង់ជាតិ​ខ្មែរ ​នៅ​ WTO 1 Jan, 2015 05:00 បុគ្គលជោគជ័យ, រស់ជីវិត 8  Comment (s) ថ្ងៃទីមួយនៃឆ្នាំថ្មី បើអត់ទាន់ទៅណា ជួបជាមួយ​អ្នកលើក​ទង់ជាតិខ្មែរនៅ WTO សិន? នេះជា​បទសម្ភាសន៍​ពិសេស​​រវាង និ…

Read more »
23 Feb 2016

៧​ឃ្លា ​​​បុគ្គល​ជោគជ័យ​នានា​​មិន​ដែល​និយាយ​

៧​ឃ្លា ​​​បុគ្គល​ជោគជ័យ​នានា​​មិន​ដែល​និយាយ​ 24 Feb, 2016 10:05 បុគ្គលជោគជ័យ, បុគ្គលបច្ចេកវិទ្យា 0  Comment (s) ​ភាព​ជោគជ័យ​​​ មិន​មែន​ជា​អ្វី​ដែល​អាច​សម្រេច​​បាន​តែ​​មួយ​ថ្ងៃ ឬ​មួយ​យប់​បាន​ទេ​ ​តែ​ត…

Read more »
23 Feb 2016

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 strange issue. Config: - added an HTTP Cookie Manager at the top of my threa…

Read more »
10 Feb 2016

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 Select Team -> Ignored Resources Click on Add Pattern and enter "bin" Cli…

Read more »
20 Jan 2016

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 »
23 Dec 2015

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 world, the locale-specific data is stored in message resource files. I…

Read more »
Load more posts
 
 
 
Top