如何本地化 Flex/Actionscript“枚举”确保可绑定性?
我有一个模拟枚举,如下所示:
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;
}
}
以及绑定到这些枚举的按钮,如下所示:
<mx:Button label="{Sport.BASEBALL.label}" toolTip="{Sport.BASEBALL.description}"/>
我现在需要本地化此枚举,但是当我更新区域设置时,没有太多运气让绑定与其他所有内容一起更新:
resourceManager.localeChain = [ localeComboBox.selectedItem ];
我'我尝试将 getters 绑定到应该由 ResourceManager 抛出的“change”事件,但这似乎不起作用。有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
其中
Sport.BASEBALL.label
和Sport.BASEBALL.description
是 ResourceBundle 中的键。您还可以查看 BabelFx ,它消除了插入所有那些难看的
{resourceManager.getString(. ..)}
语句。它使用运行时注入来本地化您的应用程序。You could use
where
Sport.BASEBALL.label
andSport.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.