January 02, 2004

quick review of resource bundles methods for cf

first let me dispatch the notion of using cf code in lieu of resourceBundles (rb). its a bad habit that might work with very small files for a couple of languages but will eventually breakdown as your g11n apps become more complex and cover more and more languages (locales). so if you're just beginning g11n work, don't start with this method no matter how tempting it looks. and if you're already using this approach, quit while you're ahead. mingling code and text like that is just a bad idea. last year (well last week) i was mildly berated by some java folks for suggesting the use of either utf-8 based cf "resourceBundles" or the PropertyResourceBundle java class instead of the more typical ResourceBundle. oh the shame, but from a cf prespective though, those java folks were just being sort of snobbish. depending on your cf app needs it seems acceptable to me to use either rb method. below you'll find a quick and dirty comparison between the two less "normal" methods and the more traditional java method. each has their good and bad points however for me the biggest negative associated with using the "pure" java ResourceBundle approach is it's requirement that rb always be in a classpath. thats a show stopper for many shared hosts. though it won't stop me from releasing an rb CFC using that style ;-) CFMX UTF-8 pros - human readable - easy to manage (notepad, etc.) - simple to implement in MX - quite fast cons - complex rb quickly become hard to manage - can't easily use standard rb tools java ResourceBundle pros - pure standard java rb solution - handles rb from standard tools - self determines rb for locale - handles complex rb quite easily cons - not human readable - requires rb be somewhere in classpath - requires createObject permission - some overhead in using java object java PropertyResourceBundle pros - rb can be anywhere - pure standard java rb solution - handles rb from standard tools - handles complex rb quite easily cons - not human readable - requires caller to determine rb from locale - requires createObject permission - some overhead in using java object i'd appreciate any feedback on this.

0 Comments:

Post a Comment

<< Home