国际化 Flex 应用程序的最佳实践? [英] Best Practices for Internationalizing a Flex Application?

查看:32
本文介绍了国际化 Flex 应用程序的最佳实践?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑将我正在开发的 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)
  • 需要能够在运行时切换

推荐答案

当然,在谷歌搜索之后,我发现了一篇关于 运行时本地化.

Of course, after googling a bit more I come across an article on runtime localization.

并遵循以下步骤:

将以下内容添加到编译器参数以指定支持的语言环境及其路径:(在 Flex Builder 中,选择项目并转到属性 -> Flex Compiler -> Additional Compiler Arguments)

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-path=locale/{locale}

创建以下文件:

src/locale/en_CA/resources.properties
src/locale/fr_CA/resources.properties

然后编译器报错:unable to open 'C:\Program Files\Adobe\Flex Builder 3\sdks\3.1.0\frameworks\locale\en_CA'

这看起来与错误 SDK-12507

解决办法:
sdks\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/locale/en_CA/resources.properties 文件中:

windowTitle=Window Title
name=Name

这篇关于国际化 Flex 应用程序的最佳实践?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆