最佳实践国际化在Flex应用程序? [英] Best Practices for Internationalizing a Flex Application?
问题描述
我要寻找到一个国际化Flex应用程序我的工作,我很好奇,如果有这样做的任何的最佳做法或建议。
I am looking into internationalizing a Flex application I am working on and I am curious if there are any best practices or recommendations for doing so.
谷歌搜索这样的信息结果在一把小物品和博客,每次约做不同的看法,其优点和缺点是不完全清楚。
Googling for such information results in a handful of small articles and blog posts, each about doing it differently, and the advantages and disadvantages are not exactly clear.
编辑以狭隘的范围:
- 需要只支持两种语言(en_CA和fr_CA)
- 需要能够在运行时切换
推荐答案
当然,谷歌上搜索了一下经过我碰到过一篇关于<一个href="http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:_Runtime_Localization">runtime本地化。
Of course, after googling a bit more I come across an article on runtime localization.
和执行这些步骤:
添加以下的编译器参数指定支持的语言环境和它们的路径: (在Flex Builder中,选择项目,进入属性 - > Flex编译器 - >附加的编译器参数)
Add the following to the compiler arguments to specify the supported locales and their path: (In Flex Builder, select project and go properties -> Flex Compiler -> Additional Compiler Arguments)
-locale = en_CA,fr_CA -source路径=区域/ {区域设置}
创建以下文件:
src/locale/en_CA/resources.properties
src/locale/fr_CA/resources.properties
然后编译器会抱怨:无法打开C:\ Program Files文件\的Adobe \的Flex Builder 3 \的SDK \ 3.1.0 \框架\区域设置\ en_CA
这看起来是与错误 SDK-12507
解决方法:
在的SDK \ 3.1.0 \ BIN
目录,执行以下命令:
Work around:
In the sdks\3.1.0\bin
directory, execute the following commands:
copylocale en_US en_CA
copylocale en_US fr_CA
这将创建在Flex Builder安装的语言环境目录,并建立所需的资源放进去。
This will create the locale directories in the Flex Builder installation and build some required resources into them.
然后在你的的.mxml
文件,参考资源包:
Then in your .mxml
files, reference the resource bundle:
<mx:Metadata>
[ResourceBundle("resources")]
</mx:Metadata>
和国际化的字符串:
<mx:TitleWindow title="Window Title">
变成了:
<mx:TitleWindow
title="{resourceManager.getString('resources', 'windowTitle')}">
和
var name:String = "Name";
变成了:
var name:String = resourceManager.getString("resources", "name");
而在你的的src /区域/ en_CA / resources.properties
文件:
windowTitle=Window Title
name=Name
这篇关于最佳实践国际化在Flex应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!