Thursday, September 20, 2007

Flex Bug? Confirmed

A little while ago I posted about a weird Flex bug. I believe I have solved the problem and confirmed it is in fact a bug. A little more information about the problem is probably necessary. The way my app is set up, I have a Module that I used to load in all the translations for a handful of languages. Each of those languages' set of translations is in its own properties file. I create all the variables like so:

[ResourceBundle("application")]
private var rb:ResourceBundle;


[ResourceBundle("application_de")]
private var rb_de:ResourceBundle;


[ResourceBundle("application_es")]
private var rb_es:ResourceBundle;


[ResourceBundle("application_fr_CA")]
private var rb_fr_CA:ResourceBundle;


[ResourceBundle("application_fr")]
private var rb_fr:ResourceBundle;


I stick all this into a static class so I can do something like Translations.get("myKey");

In my last post I discovered that the rb_fr variable was null. And if I switch the order of the rb_fr and the rb_fr_CA definitions in my code, then the rb_fr_CA variable would be null. I initially thought it had something to do with the naming. Possible related to the underscore character. After pulling my hair out I discovered that it isn't that. In fact which ever one is defined last is null. So if I add another one to the end it will be null and all previous ones work. The strangest part of all this is that if I do the same thing direction in my Application instead of in a Module, the problem doesn't seem to exist.

In the end all this probably is a moot point since Flex 3 will give us the ability to do runtime locale changes, which is really what I was trying to accomplish. I really didn't want to have to compile my application 5 times; once for each locale.

2 comments:

Matt said...

Still worth filing a bug at http://bugs.adobe.com/flex :-)

Jurassic said...

So how did you fix it anyway? I am currently having the exact same problem, and I don't use modules, just static class inside the application with series of [ResourceBundle] (I have 17 of them). Sometimes I get 12 of 'em working, sometimes 15, but never all 17. Could you share your solution please?