Isn't the danger here that Text() will explode if for some reason default was null (e.g Reading from a DB)?
It's not a massive issue, as people should be diligent about supplying defaults but it's just a though. Cheers, Tim Sent from my iPhone On 6 Mar 2009, at 18:32, Derek Chen-Becker <dchenbec...@gmail.com> wrote: > It would be a little cleaner if there was a helper overload: > > def loc (key : String, default : String) = loc(key, Text(default)) > > Derek > > On Fri, Mar 6, 2009 at 12:16 PM, Timothy Perrett <timo...@getintheloop.eu > > wrote: > > I've just been looking at some of the other method overloads in S and > it appears we already have: > > S.loc(String, NodeSeq) > > This is exactly what I need anyway - wondering if there is any need to > override S.? with another method now? > > Cheers, Tim > > On Mar 6, 5:03 pm, Timothy Perrett <timo...@getintheloop.eu> wrote: > > Sounds cool - I'll make the change and commit it. > > > > Cheers, Tim > > > > On 06/03/2009 16:56, "marius d." <marius.dan...@gmail.com> wrote: > > > > > > > > > +1 for overloading '? ' > > > > > On Mar 6, 4:52 pm, Derek Chen-Becker <dchenbec...@gmail.com> > wrote: > > >> I think this is a reasonable addition, but I would use > > > > >> def ?(key : String, defaultKey : String) = ... > > > > >> That way changing the default text just doesn't require changes > to code. > > > > >> Derek > > > > >> On Fri, Mar 6, 2009 at 6:29 AM, Tim Perrett > <timo...@getintheloop.eu> wrote: > > > > >>> Guys, > > > > >>> I have a situation where I want to localize a bunch of dynamic > texts, > > >>> however the current behavior of S.? is to return the input > text if its > > >>> found in a resource bundle. Whilst I see the rational for > this, I have > > >>> another situation where I want to pass a key, and if it > doesn't find > > >>> it, display something else (the english version). Id rather > not use > > >>> the english text as the translation key, as if the english text > > >>> changes, my database translations will break (not good!) > > > > >>> I can achieve the functionality needed right by doing > something like: > > > > >>> S.loc(item.localization_key.toString + ".name") match { > > >>> case Full(t) => t > > >>> case _ => Text(doc.name.toString) > > >>> } > > > > >>> But it would be nice if we could have a utility method in S > which > > >>> allowed you do do: > > > > >>> ?("my.localization.key", defaultText.toString) > > > > >>> Thoughts? > > > > >>> Cheers, Tim > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---