Results 1 to 3 of 3

Thread: Resolved Locale/Language

  1. #1
    Join Date
    Jan 2010
    Posts
    2

    Default Resolved Locale/Language

    Is there a way to determine which language/locale is being displayed to the user? For example I have 3 language files:

    language.properties (default english)
    language_fr.properties (french)
    language_dk.properties (german)

    The browser locale is set to "es" (spanish) so it defaults to language.properties file. How can I determine which language/properties file is being used by Spring? LocaleResolver picks up the Accept-Header or uses cookies to determine which locale the browser is requesting but not the locale/language the server will use.

    Is there a way to determine which language is actually being used?

  2. #2
    Join Date
    May 2005
    Posts
    288

    Default

    A LocaleResolver determines, which locale will be used. Read more here: http://static.springsource.org/sprin...localeresolver.

    The property file providing the localized message text can only be determined on a per-message-basis. If you need to know the property file for test purposes, it might be a good idea to create copies of your property files and append the loacle name behind each message text. That shouldn't be too hard to do with a proper editor. Then point the context to your copies. This will look very ugly, but will give you the information needed.

    HTH

  3. #3

    Default

    You could try using Springs ThreadLocal strategy for setting the current locale for the request thread.

    Code:
    LocaleContextHolder.getLocaleContext().getLocale();

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
  •