Announcement Announcement Module
Collapse
No announcement yet.
Resolved Locale/Language Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


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

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

      Comment

      Working...
      X