January 16, 2004

resourceBundle gotcha

continuing in the same week long obsession with resource bundles, i thought i'd point out a potential "gotcha" concerning the java flavored resourceBundles before it induced any psychotic episodes--cf folks used to dealing with structures (or those people using the cf-based UTF-8 resourceBundles) might be particularly susceptible to this. using cf structures you could always build a key value pair like (i don't think its such a hot idea but you could): montyPython=structNew(); montyPython["ministry of silly walks"]="too funny for words"; as long as you referenced the montyPython structure using this sort of syntax montyPython["ministry of silly walks"] all was well with the world. you could just as easily use this style in cf-based UTF-8 resourceBundles (again not a good idea but you could): ministry of silly walks=too funny for words because the resourceBundle CFC (or whatever you're using but should behave similarly) would simply parse this as a list delimited with an "=", stuffing the left side into a structure as a key with the right side as that key's value. fine and dandy but this won't cut it with java flavored resourceBundles. "why" you ask? because java resourceBundles' keys are defined (according to the java.util.Properties API) as: "The key consists of all the characters in the line starting with the first non-whitespace character and up to, but not including, the first ASCII =, :, or whitespace character." so "ministry of silly walks=too funny for words" would be equivalent to "ministry=of" when parsed by either of the two java resourceBundle classes i've been going on about lately. and that of course might cause a bit of head scratching and finger pointing.... so now you know.

0 Comments:

Post a Comment

<< Home