How to use different file path for "messages" file?

31 views
Skip to first unread message

Rambabu Posa

unread,
Nov 27, 2017, 10:40:19 AM11/27/17
to Play framework dev
Hi

We are using Play 2.5.12 and doing some unit tests for Play Views.
Is it possible to refer different file path for "messages" file? Its only for unit testing purpose

Something like : /conf/messages file  for actual messages
test/resources/messages file for unit tests expected messages

We want to keep two set of messages files so that we can have separate expected messages.

Please suggest me on this.

Many thanks,
Ram

Greg Methvin

unread,
Dec 18, 2017, 1:01:38 AM12/18/17
to Play framework dev
Hi Ram,

Currently the "messages" name is hard-coded but it should be possible to override a method and bind a custom implementation of DefaultMessagesApi. See https://github.com/playframework/playframework/blob/2.6.9/framework/src/play/src/main/scala/play/api/i18n/Messages.scala#L541. You will probably want to use different places on the classpath though. /conf/messages and test/resources/messages are the same path on the classpath since "conf" behaves like a resource directory. You could also just override the MessagesApi binding to your own custom implementation in your tests.

Also, this would probably be a better question for the main play-framework mailing list: https://groups.google.com/forum/#!forum/play-framework

Cheers,
Greg
Reply all
Reply to author
Forward
0 new messages