Book Image

Play Framework essentials

By : Julien Richard-Foy
Book Image

Play Framework essentials

By: Julien Richard-Foy

Overview of this book

Table of Contents (14 chapters)
Play Framework Essentials
About the Author
About the Reviewers

Serving content in several languages

Play comes with handy support for internationalization so that you can define the messages of your application in several languages and automatically select the language to use according to the user preferences (as defined by the Accept-Language request header).

When a user performs a request to a server from his web browser, this one usually sets an Accept-Language header according to the user preferences. For instance, in my case, it is the following:


This means that the language I prefer to read is English and then French. The preference level is defined by the q factor. If there is no q factor associated with a language (for instance, en, in the preceding code), its value defaults to 1 (highest preference).

So, when I request a page, the server should serve the English version of the page if it has one, or the French version. This means that the server has to choose, among the languages it supports,...