Is "ignorance" an acceptable answer? ;)

Fixing it up now.

On Fri, Feb 27, 2009 at 12:02 PM, marius d. <[email protected]> wrote:

>
> Any reason why not use  NamedPF.applyBox ?
>
> On Feb 27, 7:12 pm, Derek Chen-Becker <[email protected]> wrote:
> > Take 3. Change the factory application to:
> >
> >
> LiftRules.resourceBundleFactories.toList.find(_.isDefinedAt(locale)).toList.map(_.apply(locale))
> >
> > Derek
> >
> > On Fri, Feb 27, 2009 at 11:05 AM, Derek Chen-Becker
> > <[email protected]>wrote:
> >
> > > Tim, I just noticed that the PF type should be:
> >
> > > type ResourceBundleFactoryPF =
> > > PartialFunction[(String,Locale),Box[ResourceBundle]]
> >
> > > The reason we wanted to use PFs was to allow specialization for a
> specific
> > > language. I'm wondering whether the string parameter is really
> necessary,
> > > since really that's intended to look up a bundle name via
> > > ResourceBundle.getBundle. That would change the proposed code to:
> >
> > > type ResourceBundleFactoryPF =
> PartialFunction[Locale,Box[ResourceBundle]]
> > > var resourceBundleFactories : RulesSeq[ResourceBundleFactory]
> >
> > > // In S.scala
> > > def resourceBundles : List[ResourceBundle] =
> > > ...
> > > case Nil => _resBundle.set(LiftRules.resourceNames.flatMap(name =>
> > > tryo {
> > >  List(ResourceBundle.getBundle(name, locale))
> > > } openOr {
> > >  // I think this is right...
> > >
>  
> LiftRules.resourceBundleFactories.toList.find(_.isDefinedAt(locale)).map(_.apply(locale))
> > > openOr Nil
> > > }))
> >
> > > Derek
> >
> > > On Fri, Feb 27, 2009 at 9:58 AM, Tim Perrett <[email protected]
> >wrote:
> >
> > >> Guys,
> >
> > >> Me and Derek have just been chatting over IM debating the whole
> > >> resource bundle loading mech in Lift. As you know, im working on this
> > >> database localization stuff right now as I need it for work.
> >
> > >> Right now, were loading bundles using the normal
> > >> ResourceBundle.getBundle methods from Java. Whilst this is good for
> > >> most applications, when you need flexibility to do more compelx
> > >> localization, it falls down a bit.
> >
> > >> Id like to propose adding a configurable "bundle factory" to
> > >> LiftRules, so that we provide a localization hook. Something like:
> >
> > >> // LiftRules.scala
> > >> type ResourceBundleFactoryPF = (String,Locale) => Box[ResourceBundle]
> > >> var resourceBundleFactories : RulesSeq[ResourceBundleFactory]
> >
> > >> Then, in S.scala where we load the bundles, rather than having openOr
> > >> Nil, it could fall through to the custom loaders like so:
> >
> > >> case Nil => _resBundle.set(LiftRules.resourceNames.flatMap(name =>
> > >> tryo {
> > >>  List(ResourceBundle.getBundle(name, locale))
> > >> } openOr {
> > >>  // load bundle factories, do something
> > >>  // here to load them (not sure what yet!)
> > >>  LiftRules.resourceBundleFactories
> > >> }))
> >
> > >> Then in Boot.scala you could do:
> >
> > >> LiftRules.resourceBundleFactories.prepend {
> > >>  case (basename, locale) => DBResourceBundle(basename, locale)
> > >> }
> >
> > >> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to