i am trying to get i18n localisation working on an Grails/Groovy enum,
public enum Notification {
GENERIC(0),
CONFIRM_RESERVATION(100),
CONFIRM_ORDE
You need to implement MessageSourceResolvable
to provide your codes:
enum Notification implements org.springframework.context.MessageSourceResolvable {
GENERIC(0),
CONFIRM_RESERVATION(100),
CONFIRM_ORDER(200),
CONFIRM_PAYMENT(300),
final int id;
private Notification(int id) {
this.id = id
}
String toString() {
id.toString()
}
String getKey() {
name()
}
public Object[] getArguments() { [] as Object[] }
//This methods do the trick
public String[] getCodes() { [ "notification." + name() ] }
public String getDefaultMessage() { name() }
}
And define your messages in i18n:
notification.GENERIC=Generic
notification.CONFIRM_RESERVATION=Confirm reservation
notification.CONFIRM_ORDER=Confirm order
notification.CONFIRM_PAYMENT=Confirm payment
The select tag should look like this: