No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
project Bintray release working Oct 1, 2013
src Remove unused import Oct 1, 2013
.gitignore Initial commit Oct 1, 2013
.travis.yml Rename travis file Oct 1, 2013
LICENSE Initial commit Oct 1, 2013
build.sbt Bintray release working Oct 1, 2013


Build Status

scala-i18n is a very thin Scala wrapper around Java's java.util.ResourceBundle to make it a bit nicer to use from Scala code.


resolvers += "bintray" at ""

libraryDependencies += "com.netaporter" %% "scala-i18n" % "0.1"

Getting Started

Provided you have you resource bundle files like so:


You can create a ResourceBundle reference like so:

val messages = ResourceBundle("messages/messages")

Then you can call methods like so:

Returns the value for the message key my.greeting.message from the

val message = messages.get("my.greeting.message", Locale.CANADA_FRENCH)

If the message key does not exist in the file, it will fallback and try the If the message still doesn't exist, it will fallback and try the root file.

If the message key does not exist in any files, then get will throw a MissingResourceException. Alternatively you can use the find method that will either return a Some(message) when a message with the specified key exists or a None when NO message with the specified key exists.

messages.find("my.greeting.message", Locale.ENGLISH) == Some("Hello!")
messages.find("my.non.existent.message", Locale.ENGLISH) == None


getOrElse lets you specify a default in the instance that no message exists for the specified key:

messages.getOrElse("my.greeting.message", Locale.ENGLISH, "Default!") == "Hello!"
messages.getOrElse("my.non.existent.message", Locale.ENGLISH, "Default!") == "Default!"


You can specify parameters in a resource bundle file like so:

my.greeting.message=Hello {0}, you look {1}

The you may use getWithParams or findWithParams like so:

val message = messages.getWithParams("my.greeting.message", Locale.ENGLISH, "Joe Bloggs", "awful")
message == "Hello Joe Bloggs, you look awful"


scala-i18n is open source software released under the Apache 2 License.