Reputation: 8578
I used the instructions from here: http://www.playframework.org/documentation/1.2.1/i18n
and created files for different languages.
I call play.i18n.Lang.change method to change the language file, and it still takes the captions from the English file ("messages" without a suffix),
Any ideas why?
Upvotes: 1
Views: 2489
Reputation: 319
In my specific case I had
play.http.session.domain
set to something else other than localhost
while testing.
Upvotes: 0
Reputation: 54894
It is hard to know from your description exactly what the problem may be, so I have outlined how you should do a multi-lingual app.
There are a number of steps you must follow to get internationalisation to work. Firstly, you must change your application.conf
file to declare your supported languages.
So, if you are supporting English and French, you would do
application.langs=en,fr
You must then create the language file for your French translation called messages.fr
. The English language would just stay in the standard messages
file. In this new file, add your name value pairs for the key and message.
The way Play processes the messages, is to look first in the locale specific message file first (so for english it would be messages.en
, which does not exist, and for french it would be messages.fr
). If the message cannot be found in the locale specific message file, it will look at the global message file. So your global messages
file acts as the catch all.
Then, in your code, set the language for your particular user, using
Lang.change("fr"); // change language to French
Remember, that this will save a cookie for the particular user in a PLAY_LANG cookie, so check that this cookie is being created for the user.
Final note, make sure that your files are UTF8 encoded. It causes problems if it is not.
Upvotes: 8