Grails and Arabic localization

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 :

  1. I made a new file called messages_ar.properties that contains the arabic localization under the i18n folder.
  2. I made a simple beforeinterceptor:
    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!