In my Play! 2.0 application I would like to define the following languages:
# The application languages
# ~~~~~
application.langs=en-GB,de-DE,nl-NL
I also have created 3 files that ends with the corresponding language codes:
Messages.en-GB
Messages.de-DE
Messages.nl-NL
When I start the application without any request for a translated key I get the following error message:
conf/application.conf: 12: Key 'de-DE' may not be followed by token: ',' (if you intended ',' to be part of the value for 'de-DE', try enclosing the value in double quotes)
Also when trying to access a message from the Scala template I still see the same message. I request the message by the following code:
@Messages("login.page")
The above changes I have done according to the Play manual: http://www.playframework.org/documentation/2.0/JavaI18N . So I have two questions:
- How can I set the default langauge and change it like in 1.2.4 (Lang.change("en-GB"))
- How to access the messages from the Scala templates?
Changing the language is not possible in Play! 2.0, see this discussion: http://groups.google.com/group/play-framework/browse_thread/thread/744d523c169333ac/5bfe28732a6efd89?show_docid=5bfe28732a6efd89
and this ticket: https://play.lighthouseapp.com/projects/82401-play-20/tickets/174-20-i18n-add-ability-to-define-implicit-lang-for-java-api#ticket-174-4
Although, when you register multiple languages you should enclose them in double qoutes, like this:
And then you can access them from the scala templates like this:
So currently the default language is the language that is defined in the file messages (without any prefix!!)
Or you can just use @Messages("not.logged.in")
In your scala file use:
And in your java file use :
Don't forget to add quote around your language list : conf/application.conf