January 1, 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 using either utf-8 based cf "resourceBundles" or using 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 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 pros and cons 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 ;-)
| resourceBundle style | pro | con |
| CFMX UTF-8 | - human readable
- easy to manage (notepad, etc.)
- simple to implement in MX
- quite fast
| - complex rb quickly become hard to manage
- can't easily use standard rb tools
|
| java ResourceBundle | - pure standard java rb solution
- handles rb from standard tools
- self determines rb for locale
- handles complex rb quite easily
| - not human readable
- requires rb be somewhere in classpath
- requires createObject permission
- some overhead in using java object
|
| java PropertyResourceBundle | - rb can be anywhere
- pure standard java rb solution
- handles rb from standard tools
- handles complex rb quite easily
| - 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.
Comments
Hi Paul, I tried to implement your resourcebundlecfc for cfmx utf8. I got your test script to work. Nice.
But I do not know how to implement die cfscript block in my application.cfm.
It does not find the variables in the structure. Maybe it's not possible to put cfscript in the Application.cfm?
Do you have a suggestion?
Any help is appriciated. Kind regards Thorsten
Posted By Thorsten / Posted At 5/9/05 1:29 PM
it should work though i'd suggest using javaRB.cfc instead along w/rbManager to handle the rb.
Posted By PaulH / Posted At 5/9/05 2:48 PM