play.ext.i18n.loaders.PropertyFileLoader.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of play-i18n_2.11 Show documentation
Show all versions of play-i18n_2.11 Show documentation
Messaging localization plugin for the Play framework 2
package play.ext.i18n.loaders
import play.api.PlayException.ExceptionSource
import play.api.i18n.Messages.MessageSource
import play.api.i18n.MessagesParser
import play.ext.i18n.MessagesLoader
/** Loader of common property files, implementation taken from Play framework core
*
* @author Karel Cemus
*/
class PropertyFileLoader extends MessagesLoader {
override def apply(messageSource: MessageSource, messageSourceName: String): Either[ExceptionSource, Map[String, String]] = {
new MessagesParser(messageSource, "").parse.right.map { messages =>
messages.map { message => message.key -> message.pattern }.toMap
}
}
}