framework
framework copied to clipboard
LiftRules.localizationLookupFailureNotice is not called on S.loc("xxxxxxxx")
In reference of : http://groups.google.com/group/liftweb/browse_thread/thread/0e5f52077ef15395/a31dacb5110656cc#a31dacb5110656cc
Hello,
So if I overload LiftRules.localizationLookupFailureNotice to log notices to error log then errors are generated on S.??("xxxxxxxx") but not on S.loc("xxxxxxxx") or Not Found. Can we improve lift localization to avoid this?
Lift version : 2.4
At looks like S.loc logs for each resourceBundle that is tried and no key found. If there are no resourceBundles, no logging occurs.
This does seem a bit odd an in contrast to S.? that only logs once for the key even if there are multiple bundles.
I'm looking at some other stuff with resources so please open a ticket and assign it to me (on GitHub)
/Jeppe
S.loc code:
def loc(str: String): Box[NodeSeq] =
resourceBundles.flatMap(r => tryo(r.getObject(str) match {
case null => LiftRules.localizationLookupFailureNotice.foreach(_(str, locale)); Empty
case s: String => Full(LiftRules.localizeStringToXml(s))
case g: Group => Full(g)
case e: Elem => Full(e)
case n: Node => Full(n)
case ns: NodeSeq => Full(ns)
case x => Full(Text(x.toString))
}).flatMap(s => s)).find(e => true)
S.?! code:
private def ?!(str: String, resBundle: List[ResourceBundle]): String = resBundle.flatMap(r => tryo(r.getObject(str) match {
case s: String => Full(s)
case n: Node => Full(n.text)
case ns: NodeSeq => Full(ns.text)
case _ => Empty
}).flatMap(s => s)).find(s => true) getOrElse {
LiftRules.localizationLookupFailureNotice.foreach(_(str, locale));
str
}
So I guess these should look identical except for the handling of non-empty/null contents?
I am currently working with this feature. One annoying thing about that code you posted:
def loc(str: String): Box[NodeSeq]
is called every time I use the Loc snippet. The tryo()
block swallows Exceptions from getObject()
, including the MissingResourceException
which would be so helpful to track.
Is it possible to update this in a way that LiftRules.localizationLookupFailureNotice
is called every time a resource is missing? It seems like this is the intend
Please try posting to the mailing list, as comments on really old issues usually require additional context best provided there. We can bring the discussion back here once an active committer understands what's up and expresses a willingness to change things (or if someone decides to submit a PR). Either way, discussion on the mailing list is the first step :)