apache-flex - 如何本地化 Flex/Actionscript "enums"以确保可绑定(bind)性?

标签 apache-flex actionscript flex3 localization resourcemanager

我有一个模拟枚举,如下所示:

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;
    }
}

绑定(bind)到这些枚举的按钮如下:

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

我现在需要本地化这个枚举,但是当我更新区域设置时,绑定(bind)与其他所有内容一起更新的运气并不好:

resourceManager.localeChain = [ localeComboBox.selectedItem ];

我尝试将 getter 绑定(bind)到应该由 ResourceManager 抛出的“change”事件,但这似乎不起作用。有什么想法吗?

最佳答案

你可以使用

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

其中 Sport.BASEBALL.labelSport.BASEBALL.description 是您的 ResourceBundle 中的键。

您还可以查看BabelFx这消除了插入所有那些丑陋的 {resourceManager.getString(...)} 语句的需要。它使用运行时注入(inject)来本地化您的应用程序。

关于apache-flex - 如何本地化 Flex/Actionscript "enums"以确保可绑定(bind)性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4001923/

相关文章:

flash - 是什么导致 flash/actionscript 运行时错误 "WatcherSetupUtil is not defined"?

flash - Flex声音提取并保存mp3

actionscript-3 - 在 Adob​​e AIR 应用程序中创建通知窗口

css - 你如何设计 VBox 中的间隙?

apache-flex - 如何在运行时更改 Flex 3.5 应用程序的应用程序背景颜色?

apache-flex - 弹性 : What's the difference between an MXML "Component" and an MXML "Module"?

apache-flex - 将 VBox 动态更改为 HBox

linux - 在 Apache 上启用 .swf 文件

actionscript-3 - ActionScript 3 : Changing button text

javascript - 从矩阵中获取 Angular