2

I dont want to hardcode the 'training.defaultStartTime' value in config.groovy Instead I have to read it from message.properties, The result will be like this

In message.properties

dev.training.defaultStartTime = 09:00
prod.training.defaultStartTime = 10:00

In config.groovy

  environments {
        development {
            training.defaultStartTime = message of  code 'dev.training.defaultStartTime' in message.properties 

        }
        production {
            training.defaultStartTime = message of code 'prod.training.defaultStartTime' in message.properties 
        }
    }
n92
  • 7,424
  • 27
  • 93
  • 129
  • Why hardcode it in message.properties rather than config.groovy? – tim_yates Jul 25 '12 at 08:10
  • For the internationalization purpose, I want to use message.properties.I have many default values which are different for different countries – n92 Jul 25 '12 at 08:14
  • But those will be loaded on application startup, and will not relate to the location of the user viewing the site... – tim_yates Jul 25 '12 at 08:16
  • @Vinay: Have you find solution of the issue? – MKB May 12 '14 at 12:40
  • possible duplicate of [groovy: How to access to properties file?](http://stackoverflow.com/questions/2055959/groovy-how-to-access-to-properties-file) – grepit Sep 30 '14 at 15:44

1 Answers1

2

Just want to read it? If you want to display it in a gsp, use <g:message code="dev.training.defaultStartTime"/>, (you can find some useful stuff about it here).

If you're in a controller and want to use it there, go with:

message(code: 'dev.training.defaultStartTime')
Tiago Farias
  • 3,397
  • 1
  • 27
  • 30