Search code examples
actionscript-3apache-flexairresources

'cascading' resource bundles flex/AS3


I have an adobe Air App that uses localization. The app uses the resources defined in /locale/en_US/resources.properties by default, but the user can switch to french via a flag in our data.

My question is rather simple, but I haven't been able to find relevant documentation...

I want the app to default to the resource entry in the en_US bundle if that particular entry is not found in the fr_FR bundle.

So if I call {resourceManager.getString('resources','foo.bar')} but foo.bar isn't defined in the French bundle (and the user logged in is french), it defaults to what I defined in the English one.

Has anyone made something like this work in an Air app?

Thanks!


Solution

  • You need to set localeChain on resourceManager to an array where the first value is the primary language and the second is the fallback. Should be something like this:

    resourceManager.localeChain = [ "fr_FR", "en_US" ];
    

    This will tell Flex to first look for the key in the fr_FR resources and, if that doesn't exist, fall back to the en_US resources.