Documentation

Management

Play Framework app internationalization and localization

Play Framework apps localization and internationalization. See how to translate Play apps and which language file formats are supported. 2 min read

Play Framework is a high-velocity reactive web framework for Java and Scala. It is based on a lightweight, stateless, web-friendly architecture and features predictable and minimal resource consumption (CPU, memory, threads) for highly-scalable applications.

Created by
Guillaume Bort, Zenexity
Released
May 2007
Links
https://www.playframework.com
Wikipedia

Play Framework applications are usually translated using these file formats

Best way to localize Play Framework apps

Play Framework has built-in internationalization (i18n) support. Messages are stored in files named messages, messages.en, messages.fr, etc. in the conf/ directory.

Step 1: Configure languages

In conf/application.conf, configure the languages your application supports:

properties
play.i18n.langs = [ "en", "fr", "de", "es" ]

Step 2: Create message files

Create your message files in the conf/ directory:

conf/messages (default/fallback)

properties
hello = Hello
welcome = Welcome to our application

conf/messages.fr (French)

properties
hello = Bonjour
welcome = Bienvenue dans notre application

Step 3: Use messages in your application

In Scala templates:

scala
@import play.api.i18n._
@(implicit messages: Messages)

<h1>@messages("hello")</h1>

In Java controllers:

java
public Result index(Http.Request request) {
    Messages messages = messagesApi.preferred(request);
    return ok(messages.at("hello"));
}

Step 4: Translate with WebTranslateIt

Once you have internationalized your Play Framework app, use a translation software localization tool such as WebTranslateIt to manage your localization workflow.

It is easy to translate a Play Framework app with WebTranslateIt. Create a project, upload your source messages file in the File Manager and translate it on the Translation Interface.

The tools included in WebTranslateIt, such as Batch Operations, the Translation Memory or Machine Translation can help you translate that file automatically, faster and cost effectively.

Do you know an interesting library for that platform? Have you found an error? Let us know at support@webtranslateit.com