I have made this controller, which should be used to send emails. I need to access i18n
in order to send localized emails.
class MailController {
MessageSource messageSource
static transactional = false
public void sendEmail() {
String name = "some name..."
String subject = message(code:"somemessagekey", args:[name])
// do some fancy stuff here...
}
}
There is the i18n
file then (located in i18n
folder):
file name: messages.properties
content: somemessagekey = Blabla {0} - blablabla
After I run this, it throws (in an integration test):
groovy.lang.MissingPropertyException: No such property: messageSource for class: org.codehaus.groovy.grails.support.MockApplicationContext
I am out of ideas how to handle that localization in controller (I also tried it in a service, but that is even more complicated).
If you are using grails 1.3.7, you need to declare message source as :
def messageSource
This way it will be injected into your controller. I think in 2.0 you can do it the way you posted, but it even so, I think it is worth a try to declare it as stated above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With