According to Grails' internationalization doc, i18n is accomplished by either:
- Setting an
Accept-Language
header in the request; or - Tacking on a
lang
query string param
I'm opting for the former, because its more HTTP compliant and, frankly, I just don't like adding it as a query param.
But how would I set Accept-Language
in the first place?!?
I want my app's locale to be determined by the TLD requested. So, a request for http://myapp.example.com
would return the en_US
version of my app, because *.com
is traditionally associated with English/US. If http://myapp.example.fr
was requested, then Grails should serve back the fr_FR
version of my app. Etc.
So my real question is:
How can I map the requested URL/TLD to a variable that Grails can set on the server, and then inject into GSPs, such that client-side requests always have a matching Accept-Language
header for the given URL/TLD?
Update
I want to confirm browser/Grails behavior here: is it safe to assume that when a user configures their browser, that the browser adjusts the Accept-Language
header accordingly? If so, can I also assume that if Accept-Language
is not sent, and lang
is not specified as a query param, that Grails uses en_US
by default?