A little problem that i faced with grails , was setting the locale dynamically, i followed this nice article , and here is how i could manage it :
def beforeInterceptor = { def key = "org.springframework.web.servlet.DispatcherServlet.LOCALE_RESOLVER" def localeResolver = request.getAttribute(key) localeResolver.setLocale(request, response, new Locale("ar","JO")) }
Of course you can use grails/Filters to save yourself repeating the same code in every controller.
However what i want to mention is the locale object, which in case of Arabic localization, was seeking the country argument ( “JO” in our case) :
new Locale("ar","JO")
While for other localizations like German one it doesn’t seek this second argument, so this snippet of code will work for them
new Locale("de")
Also you can change this country argument value to match this rule :
The country argument is a valid ISO Country Code. These codes are the upper-case, two-letter codes as defined by ISO-3166. You can find a full list of these codes at a number of sites, such as:
http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html
I hope that was helpful
, enjoy!
phiras | December 5th, 2008 at 12:37 pm #
Congrats for the new blog!
Abdullah | December 6th, 2008 at 9:36 am #
Congratulations