Created
December 15, 2015 16:30
-
-
Save sam/93ff9980177ee5aab7c6 to your computer and use it in GitHub Desktop.
Custom sub-project Messages overriding example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait I18nComponents { | |
def environment: Environment | |
def configuration: Configuration | |
// NOTE line 10! Load subproject messages, and override with available root project messages. | |
lazy val messagesApi: MessagesApi = new DefaultMessagesApi(environment, configuration, langs) { | |
override protected def loadAllMessages: Map[String, Map[String, String]] = { | |
langs.availables.map(_.code).map { lang => | |
(lang, loadMessages("messages.mysubproject." + lang) ++ loadMessages("messages." + lang)) | |
}.toMap | |
.+("default" -> loadMessages("messages")) | |
.+("default.play" -> loadMessages("messages.default")) | |
} | |
} | |
lazy val langs: Langs = new DefaultLangs(configuration) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment