-2

I need to internationalise the javascript messages in the frontend, I'm using play framework 2.2.1, for backend messages I followed this: http://www.playframework.com/documentation/2.0.x/ScalaI18N But I could not find anything for frontend, any ideas? Thanks!

Anna
  • 203
  • 2
  • 7
  • 23
  • That is to split the javascript code from the views, I have that, I want to internationalise the messages, put all of them in a messages file(home.title = Home) and call them from the views like this: Messages("home.title"). I case that we need to translate this web page to German, French, Spanish... all the messages are in the messages file and is easier and faster to translate, that's how i did it with the backend messages but i cannot do it in that way for the frontend messages – Anna Jan 06 '14 at 15:41
  • (re)read answers there. It's **exactly** what you're asking for (it's way to do it, localization has not to be done server side and it can be in a plain JavaScript file with something like `Messages = { HomeTitle: "Home", Index: "Index"}`). – Adriano Repetti Jan 06 '14 at 15:44

1 Answers1

0

Play has no native support for JS internationalization, anyway you can easily do it yourself using common JS files containing objects with labels + small method for finding proper translation.

Check this answer - you'll find there full implementation for Play 2.x

Community
  • 1
  • 1
biesior
  • 55,576
  • 10
  • 125
  • 182