the short question is: is there a way to change the ACCEPT_LANGUAGE Request Header before Play extracts it to determine the i18n language?
I thought that this could be accompished by overriding onRouteRequest (see http://www.playframework.com/documentation/2.2.0/ScalaInterceptors).
But it does not seem to work. This is my "test" code, see the same at https://gist.github.com/mcallisto/3f428fad87f7a7759519
import play.api._
import play.api.mvc._
import play.api.http.HeaderNames
object Global extends GlobalSettings {
override def onRouteRequest(rh: RequestHeader): Option[Handler] = {
Logger.info("Request: " + rh.toString)
Logger.info("Accepted languages : " + rh.acceptLanguages.mkString(", "))
val newLang = "it"
val newHeaders = new Headers { val data = (rh.headers.toMap
+ (HeaderNames.ACCEPT_LANGUAGE -> Seq(newLang))).toList }
val newRequestHeader = rh.copy(headers = newHeaders)
Logger.info("New accepted languages : " + newRequestHeader.acceptLanguages.mkString(", "))
super.onRouteRequest(newRequestHeader)
}
}
Without this code, i18n works according to the browser settings affecting the AcceptLanguage header.
With it, even if the header is apparently changed to the Italian ("it") language (see logger), still the i18n is given by the browser language.
At which point Play extracts the header?
Is there any other way to achieve the same goal? I would just like to reach a basic step where the request subdomain (like it.example.com) prevails against the browser settings to determine the i18n
Thank you in advance for your hints