Results 1 to 7 of 7

Thread: get current language (internationalisation)

  1. #1
    Join Date
    May 2011
    Posts
    14

    Default get current language (internationalisation)

    how can i determine the current language of the running application in spring controller?
    I need it to know which language to pass for the messageresource.getmessage..

    thx very much

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    I suggest a read of the I18N chapter in the reference guide... Also in general you want spring to handle the getting of the message instead of you doing that...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    May 2011
    Posts
    14

    Default

    Come on guys... its not like i didnt do that. ive read http://static.springsource.org/sprin...-messagesource and http://static.springsource.org/sprin...-messagesource. I dont see an example of how to determine the current language. only MessageSource handling, which i already knew.

    Can you please just tell me ?
    thx

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    As I stated read the reference guide (http://static.springsource.org/sprin...localeresolver) use a locale resolver...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    May 2011
    Posts
    14

    Default

    thx your right. i was at the wrong place

  6. #6
    Join Date
    Sep 2009
    Location
    Vilnius, Lithuania
    Posts
    118

    Default

    If your controller is an annotated @Controller, simply declare method parameter of type java.util.Locale and it will be resolved to "the current request locale (determined by the most specific locale resolver available, i.e. the configured LocaleResolver in a Servlet environment)."

  7. #7

    Default

    how about doing :

    Code:
    if (LocaleContextHolder.getLocale().getDisplayLanguage() =="English")
    regards,
    Emil

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
  •