Permalink
Browse files

[lh 314] allow overriding of default messages

  • Loading branch information...
1 parent 1580e04 commit cb2689153c96bb0333623e94c8875559c803d438 @pk11 pk11 committed Apr 6, 2012
View
2 framework/src/play/src/main/scala/play/api/i18n/Messages.scala
@@ -227,7 +227,7 @@ class MessagesPlugin(app: Application) extends Plugin {
import scalax.io.JavaConverters._
private def loadMessages(file: String): Map[String, String] = {
- app.classloader.getResources(file).asScala.map { messageFile =>
+ app.classloader.getResources(file).asScala.toList.reverse.map { messageFile =>
new Messages.MessagesParser(messageFile.asInput, messageFile.toString).parse.map { message =>
message.key -> message.pattern
}.toMap
View
1 framework/test/integrationtest/app/controllers/Application.scala
@@ -19,6 +19,7 @@ object Application extends Controller {
def index = Action {
if (Messages("home.title")(Lang("fr")) != "ffff" ) throw new RuntimeException("i18n does not work")
+ if (Messages("constraint.required") != "Hijacked" ) throw new RuntimeException("can not override default message")
val conn = play.api.db.DB.getConnection("default")
Cache.set("hello", "world")
Ok(views.html.index(Cache.getAs[String]("hello").getOrElse("oh noooz")))
View
1 framework/test/integrationtest/conf/messages
@@ -0,0 +1 @@
+constraint.required=Hijacked

0 comments on commit cb26891

Please sign in to comment.