In build.scala
, I've changed the path of message files as follows:
val main = play.Project(appName, appVersion, appDependencies).settings(
lessEntryPoints <<= baseDirectory(_ / "app" / "assets" / "stylesheets" ** "main.less"),
resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository",
resolvers += "maven2 repository" at "http://repo1.maven.org/maven2/",
unmanagedBase <<= baseDirectory(_ / ".." / "messagesFiles")
)
The messagesFiles
folder contains messages
and messages.fr
files.
At application startup a translated text is not showing up. Why?
How to set up a play application to read the messages files present in a custom location apart from conf
folder?
You haven't described your environment regarding play version so let me assume you use the recent version Play 2.2.2-RC1
. Mine is...
[myFirstApp] $ show playVersion
[info] 2.2.2-RC1
Given the play version, you can configure the project using build.sbt
in most cases. Create one if you don't have it in your project.
Add the following line to build.sbt
to point at the custom directory where language-specific message files are.
unmanagedResourceDirectories in Compile += baseDirectory.value / "messagesFiles"
I'm unsure whether it is the most recommended approach to specify the messages directory, but given how sbt works it does the trick.
You can show
the value of the unmanagedResourceDirectories
setting as follows:
[myFirstApp] $ show unmanagedResourceDirectories
[info] List(/Users/jacek/sandbox/play-ground/myFirstApp/conf, /Users/jacek/sandbox/play-ground/myFirstApp/messagesFiles)
The above output assumes the above setting in build.sbt
.
In the previous versions of Play (and hence SBT) the following in project/Build.scala
could do the trick:
unmanagedResourceDirectories in Compile <+= baseDirectory(_ / ".." / "messagesFiles" )