转 flex中ResourceBundle的用法

Flex的ResourceBundle用处主要是在runtime的时候加载一些文件,最大用处就是用做国际化。 

1、在flex中的project的property面板里选择flex compiler选项,在compiler arguments里添加参数: 
-locale en_US -source-path=../resourcebundles/{locale} -services=../services/services-config.xml
其中的{locale}就是en_US,而且en_us其实就是一个目录

2、创建配置文件(*.properties),里面都是键值对,比如name=123,old=123 ... 
----------------------------------------------------------------------------------------
welcome.title=DigiPri Widgets
statusMessage.switchView=Click on either icon to switch to the respective view
statusMessage.maximizeReport=Click to maximize report
statusMessage.removeReport=Click to remove report
statusMessage.moveReport=Click and drag to rearrange the reports
statusMessage.backTrack=Click to return to the previous report

labels.week=Week

xmlFiles.services=xml/services.xml
----------------------------------------------------------------------------------------

3、在flex程序中,绑定它。比如 
<fx:Metadata>
[ResourceBundle("crm")]
</fx:Metadata>

然后就可以用了。比如
resourceManager.getString('crm','statusMessage.backTrack') 

在ArcGIS Server For Flex API的index.mxml中就引用了

    <fx:Metadata>
[ResourceBundle("ViewerStrings")]
    </fx:Metadata>

用来设置不同的国家的语言

参考:

java.util.ResourceBundle使用详解 
http://lavasoft.blog.51cto.com/62575/184605/
原文地址:https://www.cnblogs.com/x38160/p/3179272.html