This is my Blog.

It's full of opinions on a wide range of stuff.

New Internationalization Extendability in Lift

I just committed new functionality into lift master for handling the abstraction of i18n ResourceBundles' that are powered by custom sources - for example, database driven localization, or hooking into some translation service.

Now, you can do:

 LiftRules.resourceBundleFactories.prepend { 
   case (_, locale) if locale.getISO3Language == "eng" 
      => new MyResources
   case (_, locale) if locale.getISO3Language == "swe" 
      => new MyResources_sv
   case (_, locale) => new DBResourceLoader(locale)
 }

In this example we assume that you have fictional java.util.ResourceBundle subclasses called "MyResources" and "MyResources_sv". Furthermore, if the ISO 639-3 code is not either "eng" or "swe", then it attempts to load it from another fictional ResourceBundle subclass "DBResourceLoader".

Long term, I will probably provide a ProtoDBResourceBundle or something similar, but for now, your on your own to implement the clever string and translation loading :-)

blog comments powered by Disqus