0

I am trying to use messages from the messages.properties and according to the i18n documentation. it takes to use the message(code: "some.properties.label", args: ['var1', 'vars2']) but it doesn't work. Always getting :

Caused by: groovy.lang.MissingMethodException: No signature of method: com.project.MainService.message() is applicable for argument types: (java.util.LinkedHashMap)

On the other hand when I use the messageSource.getMessage("code",null,null) it works.

Obviously I like the method in the documentation because it's straight to the point but for some reason doesn't work for me.Looks like for quite people on stackoverflow. So grails gurus, where is the catch?

Thanks

tim_yates
  • 167,322
  • 27
  • 342
  • 338
black sensei
  • 6,528
  • 22
  • 109
  • 188

1 Answers1

1

According to the stacktrace, it seems you are trying to call the message(code:'whatever' ....) method inside a service. This is why it isn't working, because it only works on controllers and TagLibs (grails' magic).

You should have a look to this answer, to see more explanations.

If you really want the controller syntax, you just have to create a method with the same parameters and call the messageSource Service.

Community
  • 1
  • 1
Joch
  • 230
  • 1
  • 9