1

我正在使用 Flex 3 中的 ResourceBundle 在多语言应用程序中工作。我在 DataGrid 中显示数据并像这样定义 DataGridColumn headerText

headerText="{localizedHeaderText('LABEL_USER_NAME')}

此函数返回用户名的本地化标签,但是当我动态选择另一种语言时,会刷新但 headerText 标签?

有什么想法吗?

谢谢

4

1 回答 1

3

Unless you make the localizedHeaderText method bindable, the binding will never be re-evaluated since it does not know about the change event of the resourceManager.

Assuming you are in a UIComponent subclass, you'll need to do the following:

  1. override resourcesChanged and dispatch a custom event
  2. add [Bindable(event="customEvent")] above the method

Sample code:

override protected function resourcesChanged():void {
    super.resourcesChanged();
    dispatchEvent(new Event("localeChange"));
}

and

[Bindable(event="localeChange")]
public function localizedHeaderText(key:String):String {
    return resourceManager.getString('resources', key);
}
于 2009-02-11T21:05:59.333 回答