Interpreting Java Playframework not working

I used the instructions here: http://www.playframework.org/documentation/1.2.1/i18n

and created files for different languages.

I call the play.i18n.Lang.change method to change the language file, and it still takes signatures from the English file ("messages" without a suffix),

Any ideas why?

+1
source share
2 answers

It is difficult to find out from your description what exactly the problem is, so I outlined how you should make a multilingual application.

To achieve internationalization, you need to follow a few steps. First, you must modify your application.conf file to declare supported languages.

So, if you support English and French, you will do

 application.langs=en,fr 

Then you must create a language file for your French translation called messages.fr . English will simply remain in the standard messages file. In this new file, add your name value pairs for the key and message.

The way to play messages is to first search first in the locale-specific message file (so for English it will be messages.en which does not exist, and for French it will be messages.fr ). If the message cannot be found in the locale-specific message file, it will search for the global message file. Thus, your global messages file acts like a catch.

Then in your code specify the language for your specific user using

 Lang.change("fr"); // change language to French 

Remember that this will save the cookie for a specific user in the cookie PLAY_LANG, so make sure that this cookie is created for the user.

Final note, make sure your files are encoded in UTF8. This causes problems if it is not.

+7
source

In my particular case, I had

 play.http.session.domain 

something other than localhost specified during testing.

0
source

Source: https://habr.com/ru/post/892658/


All Articles