0

I want to set values to message.properties file.

I have already done it in java like the following:

    Properties emailErrorMsgProp = new Properties();

    emailErrorMsgProp.load(new FileInputStream("grails-app/i18n/messages.properties"));

    emailErrorMsgProp.setProperty("ma_email_error",result.callStatusMsg.toString());

    emailErrorMsgProp.store(new FileOutputStream("grails-app/i18n/messages.properties"), null);

I also want to make it language specific.i have language specific properties files.

I would like to do the same thing in grails Service, but how would I go about it?

Hardik Patel
  • 937
  • 3
  • 14
  • 39

2 Answers2

0

Try this:

def writeToProps(key, value) {
    new File("grails-app/i18n/messages.properties").withWriterAppend { out ->
      out.writeLine "\n${key}=${value}"
    }
}
Tiago Farias
  • 3,397
  • 1
  • 27
  • 30
0

You should take a look at ReloadableResourceBundleMessageSource.

mathifonseca
  • 1,465
  • 1
  • 15
  • 17