Grails

changing locale by passing in lang param only changes locale for the request and not the whole session

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Won't Fix
  • Affects Version/s: None
  • Fix Version/s: 0.6-RC1
  • Component/s: None
  • Labels:
    None

Description

the lang parameter only set the locale per request. cookie must be set also for locale change to be persistent for the session
Need to change I18nGrailsPlugin.groovy. Add cookieName = "lang" as follows at end of doWithSpring closure:

localeResolver(CookieLocaleResolver) { cookieName = "lang" }

Activity

Hide
Sonny To added a comment -

The suggested fix requires you to directly manipulate the lang cookie.

CookieLocaleResolver is not working properly. Change to SessionLocaleResolver. works as expected.
SessionLocaleResolver can be configured in spring/resources.xml or this plugin can be changed to use the SessionLocaleResolver instead of the CookieLocaleResolver

Show
Sonny To added a comment - The suggested fix requires you to directly manipulate the lang cookie. CookieLocaleResolver is not working properly. Change to SessionLocaleResolver. works as expected. SessionLocaleResolver can be configured in spring/resources.xml or this plugin can be changed to use the SessionLocaleResolver instead of the CookieLocaleResolver
Hide
Graeme Rocher added a comment -

Ok changed to use session one

Show
Graeme Rocher added a comment - Ok changed to use session one
Hide
Sonny To added a comment -

only works with .gsp located in view directory. index.gsp in root does not work

Show
Sonny To added a comment - only works with .gsp located in view directory. index.gsp in root does not work
Hide
Graeme Rocher added a comment -

Add a URL mapping to redirect to a controller:

"/" {
	controller = "book"
  }

Soon we may make it possible to do:

"/" {
	view = "/index"
  }
Show
Graeme Rocher added a comment - Add a URL mapping to redirect to a controller:
"/" {
	controller = "book"
  }
Soon we may make it possible to do:
"/" {
	view = "/index"
  }
Hide
Christoph Lechleitner added a comment -

>only works with .gsp located in view directory. index.gsp in root does not work
Actually locale changing only works with controllers, not with views.

The former comment refers to that but does not explain.
The according issue is GRAILS-3871.

Show
Christoph Lechleitner added a comment - >only works with .gsp located in view directory. index.gsp in root does not work Actually locale changing only works with controllers, not with views. The former comment refers to that but does not explain. The according issue is GRAILS-3871.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: