What are the Advantages of Localization with Flex Resource Bundles?
Saturday, 09 August 2008
I have a project that has to be localized. I've done some localization in Flash in the past, but not in Flex. I've been reading about resource bundles. Do you know what the advantages are to using them over simple XML data?
Rather than updating compiler directives and recompiling to add a new language, why not just have an XML file that you load in at runtime? As long as the embedded fonts support the characters in the new language, that should solve the problem right? That's how I've done it in the past in Flash. It seems like they've made it more complicated in Flex by forcing a recompile to add a new language.
The main benefit of Flex’s resource bundles is that the MXML components you make can all bind to a property on a framework-provided Singleton to get their labels. It's a very useful out-of-box feature for the Flex Framework to provide.
Although you can use this approach if you’re building your Flex apps with PureMVC, you’ll find the method of loading XML at runtime (or using 'baked-in' XML) with a Proxy and distributing it to the view components by sending Notifications to the Medaitors a more natural thing to do for 2 reasons:
1.) It mirrors the process that is used to get any data into the view components from an external source. Things move from the Model tier to the View tier by Notification, not Flex binding. Inside the view component, sub-components may bind to the local reference to the data. This same process works the same for labels and tooltips. Fewer ways of doing the same thing makes the overall application easier to understand and maintain.
2.) It’s a platform-neutral way of doing it. That means it’ll be easier to migrate to/from (or integrate with) other platforms such as SilverLight or JavaFX.