Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
92 lines (62 sloc) 2.29 KB

play-messagescompiler - Messages compiler for Play 2 Scala


This humble Play plugin provides type safety for the project's messages. It adds key literals instead of using strings to reference a property.

  // becomes

Using the generated key literals saves the trouble of misspelt keys that lead to non-translated properties. A nonexistent or changed key will lead to a compilation error.


Add the following to project/plugins.sbt:

  resolvers += "Tegonal releases" at ""

  addSbtPlugin("com.tegonal" % "play-messagescompiler" % "1.0.6")

Then enable the plugin in build.sbt:

  lazy val myApp = (project in file("."))


The file conf/messages will be compiled to target/scala*/src_managed/main/conf/messages.scala

  home.title=Space: the final frontier

After importing conf.messages._ the key literals are available within your code.

  package controllers

  import play.api._
  import play.api.mvc._
  import play.api.i18n._
  import conf.messages._

  object Application extends Controller {

    def index = Action {


The plugin also supports message formats:

  // conf/messages
  home.title=Space: the final frontier, Stardate: {0}
  // within a controller

  // where this wouldn't compile


  • Type checked java.text.MessageFormat arguments (number, date, time, choice).


This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see

You can’t perform that action at this time.