views:

30

answers:

1

I have a simulated enum as follows:

public class Sport {
    public static const BASEBALL:Sport = new MyEnum("Baseball", "Baseball ...");
    public static const FOOTBALL:Sport = new MyEnum("Football", "Football ...");

    public var label:String;
    public var description:String;

    public function Sport(label:String, description:String):void {
        this.label = label;
        this.description = description;
    }
}

And buttons that bind to these enums as follows:

<mx:Button label="{Sport.BASEBALL.label}" toolTip="{Sport.BASEBALL.description}"/>

I now need to localize this enum, but haven't had much luck getting the binding to update along with everything else when I update the locale:

resourceManager.localeChain = [ localeComboBox.selectedItem ];

I've tried binding getters to the "change" event that supposedly gets thrown by ResourceManager, but that doesn't seem to work. Any ideas?

+2  A: 

You could use

<mx:Button label="{resourceManager.getString('resourceBundleName', Sport.BASEBALL.label)}" toolTip="{resourceManager.getString('resourceBundleName', Sport.BASEBALL.description)}"/>

where Sport.BASEBALL.label and Sport.BASEBALL.description are the keys from your ResourceBundle.

You can also take a look at BabelFx which eliminates the need to insert all those ugly {resourceManager.getString(...)} statements. It uses runtime injection to localize your application.

Gerhard
True, this is an option. It doesn't feel optimal, though. I'll have a look at BabelFX.
Wachunga