Grails Domains Internationalition

[ This Blog Was Moved To : ]

I am currently working at a Project that should be internationalized ( Arabic – English ).  I am still developing it. I needed list of countries to be internationalized and I wanted it to be in the domain constraints (inList). I may later put the data in the database, but for the time being; I’m putting the data in the domain class.

Here is what I did

I put the data in the model like this :

class Address {

 static constraints = {

  Date dateCreated
  Date lastUpdated

  String gpsLng
  String gpsLat

  String address
  String city
  String state
  String country

  String toString(){

And at the properties files I did the internationalization like this Samoa

And in the view .. I did this  ( I’m using beanField plugin too )

<bean:select beanName="address" property="country"
name="country" id="country"
from="${}"  valueMessagePrefix="" value="${fieldValue(bean:address,field:'country')}"   optionValue="${message(code:it)}" />

And this is it ..  The valueMessagePrefix is used to indicate the prefix to be added to the key in inList list and get the value from the properties files. optionValue is what user see ( Label ).

When the form is submitted, the value in the inList will be passed back to the controller.

Hope I was helpful to someone.