0

I'm new in Grails and try to use the i18n-plugin which is standardly integrated in the grails-framework (I use 2.2.1). I use the dynamic scaffolding and wondered that the labels of the variables of my domain model didn't changed with the values of the properties-file. That's why I tried to use the message-tag directly. But both ways don't work. I didn't change any configuration. I take a simple view an add:

<g:message code=„my.test.de.label“ />

And I add in the message.properties and message_de.properties the following entry:

test.de.label=testDE 

I opened the url with the "?lang=de" and without this parameter and nothing work. Also the labeling of the domain model via dynamic scollding didn't work. If I this g:message-tag with a code which is standardly in the propertie-file everthing is fine. And I don't understand why my custom-label don't work.

Question: - Is there any configuration I have to do? - Is there any code-error I made?

Taryn
  • 242,637
  • 56
  • 362
  • 405
Der_V
  • 177
  • 1
  • 16

1 Answers1

0

There should be no configuration you need to do except creating new messages as you need. I just created a new 2.2.1 project with a test domain class (Notification), then ran generate all for the new domain.

When I go to the list view for the new domain at http://localhost:8080/TestApp/notifications/list?lang=de I definitely see the German being used: Notifications anlegen and Notifications Liste

The only mistakes I can see in the direct use of the message tag are the commas ,, instead of quotes " and the my in my.test.de.label. This works for me:

//gsp
<g:message code="test.label" />

//messages_de.properties
test.label=testDe

You should probably NOT refer to the language in the actual message name - that sort of defeats the purpose. Every language file should have the same 'name' for the message:

//messages_de.properties
default.button.create.label=Anlegen

//messages.properties
default.button.create.label=Create

//messages_es.properties
default.button.create.label=Crear

Then use in your GSP

<g:message code="default.button.create.label" />

That way the i18n system picks it out based on the language sent from the browser.

Kelly
  • 3,709
  • 4
  • 20
  • 31
  • Hey, Thank's for help. I made an update to grails 2.2.2 and have a look at the commas and know everthing is running! :) – Der_V May 12 '13 at 19:52