I’m trying to figure out an elegant way to use resource bundles in a PAYG way
and I’m having trouble.
I’m actually not really sure how resource bundles are compiled and used in
classic Flex.
As I see it, there’s three cases where resource bundles might be used:
1. The locale is known at compile time.
2. The locale is known at app initialization.
3. The locale might be changed during runtime.
The ResourceManager classes in classic Flex is designed with #3 in mind and
it’s not very PAYG at all.
I’d venture to say that the biggest use case is #1. #2 is relatively common as
well. #3 is probably pretty rare.
For case #2, it’s probably necessary to load the resource bundles as separate
HTTP request(s) once the app initializes. I’m not sure if a default resource
bundle should be included at compile time as well. Dunno.
Case #1 seem the most straight-forward and there really should be some way to
specify resources when compiling an app.
I just committed some code which takes a stab at compile time resource strings,
but it’s kind of hacky, and I feel like there’s a better way to go about it.
Ideally, there should be some way to specify and .properties file and have it
included in the app.
To use what I committed you’d do something like this (not tested and probably
not working, but I wanted to commit the general idea):
<js:CurrencyValidator>
<js:beads>
<js:SimpleResourceStringBead
resources=“org.apache.flex.utils.validation.resources.creditcard.en_us”/>
</js:beads>
</js:CurrencyValidator>
Any ideas on how to better go about this?
Harbs