Retrieve a single message for the key
, replacing any arguments with the
values supplied.
Retrieve a single message for the key
, replacing any arguments with the
values supplied. Returns None
if the message is not found.
the lookup identifier for the message
any arguments to be supplied, how they are handled
depends upon the UniformMessages1 implementation, but
generally they are injected into the response.
Retrieve a list of values against a single key, if the key is
not found in the messages this will return Nil
Retrieve a single message against the keys
, replacing any
arguments with the values supplied.
Retrieve a single message against the keys
, replacing any
arguments with the values supplied. Throws an exception if no
message is found against any of the keys. If there are multiple
matches the first one will be used.
lookup identifiers for the message, each is tried in turn
any arguments to be supplied, how they are handled
depends upon the UniformMessages1 implementation, but
generally they are injected into the response.
Retrieve a single message for the key
, replacing any arguments with the
values supplied.
Retrieve a single message for the key
, replacing any arguments with the
values supplied. Throws an exception if the message is not
found.
the lookup identifier for the message
any arguments to be supplied, how they are handled
depends upon the UniformMessages1 implementation, but
generally they are injected into the response.
Attempt to match against key
, if a match is found return it,
otherwise attempt to find fallback values by splitting the key
into substrings using '.' (full-stop) as a separator.
Attempt to match against key
, if a match is found return it,
otherwise attempt to find fallback values by splitting the key
into substrings using '.' (full-stop) as a separator.
val m = UniformMessages.fromMap( Map("a1.b1.c1" -> List("Specific"), "b1.c1" -> List("Match2"), "c1" -> List("Very General")) ) scala> m.decompose("a1.b1.c1") res1: String = "Specific" scala> m.decompose("amodified.b1.c1") res2: String = "Match2" scala> m.decompose("amodified.bmodified.c1") res3: String = "Very General" scala> m.decompose("nonexistant") // throws exception
If still no match is found an exception is thrown.
Attempt to match against key
, if a match is found return it,
otherwise attempt to find fallback values by splitting the key
into substrings using '.' (full-stop) as a separator.
Attempt to match against key
, if a match is found return it,
otherwise attempt to find fallback values by splitting the key
into substrings using '.' (full-stop) as a separator.
val m = UniformMessages.fromMap( Map("a1.b1.c1" -> List("Match1"), "b1.c1" -> List("Match2"), "c1" -> List("Match3")) ) scala> m.decomposeOpt("a1.b1.c1") res1: Option[String] = Some(Match1) scala> m.decomposeOpt("amodified.b1.c1") res2: Option[String] = Some(Match2) scala> m.decomposeOpt("amodified.bmodified.c1") res3: Option[String] = Some(Match3) scala> m.decomposeOpt("amodified.bmodified.cmodified") res4: Option[String] = None scala> m.decomposeOpt("a1.b1.cmodified") res5: Option[String] = None
If still no match is found return None
.
Retrieve a single message against the keys
, replacing any
arguments with the values supplied.
Retrieve a single message against the keys
, replacing any
arguments with the values supplied. Returns None
if no
message is found against any of the keys. If there are multiple
matches the first one will be used.
lookup identifiers for the message, each is tried in turn
any arguments to be supplied, how they are handled
depends upon the UniformMessages1 implementation, but
generally they are injected into the response.
provides another instance using a fallback function.
provides another instance using a fallback function.
As a consequence this should never throw a NoSuchElementException.
scala> val m = UniformMessages.noop[Int].withDefault(_.size) m: ltbs.uniform.UniformMessages[Int] = ... scala> m.get("non-existant") res0: Option[Int] = None scala> m("non-existant") res1: Int = 12
A content bundle
Typically used for internationalisation but also for customisation of content on given steps of a user-journey.
This is modelled largely around the
Messages
object in the play framework - albeit with some extra capabilities (such as decomposition), but as such although it can take arguments (Any*
)it is not typesafe and has no way of knowing ahead-of-time if content is missing.Unlike play Messages however, UniformMessages are typed, can be mapped to different types and are also Monoids allowing them to be combined.