Best Practices for Internationalizing a Flex Application?

时间秒杀一切 提交于 2019-12-03 00:41:46

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

And followed these steps:

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}

Create the following files:

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

And then the compiler complains: unable to open 'C:\Program Files\Adobe\Flex Builder 3\sdks\3.1.0\frameworks\locale\en_CA'

Which looks to be related to bug SDK-12507

Work around:
In the sdks\3.1.0\bin directory, execute the following commands:

copylocale en_US en_CA  
copylocale en_US fr_CA

This will create the locale directories in the Flex Builder installation and build some required resources into them.

Then in your .mxml files, reference the resource bundle:

<mx:Metadata>
    [ResourceBundle("resources")]
</mx:Metadata>

And internationalize the strings:

<mx:TitleWindow title="Window Title">

becomes:

<mx:TitleWindow 
    title="{resourceManager.getString('resources', 'windowTitle')}">

and

var name:String = "Name";

becomes:

var name:String = resourceManager.getString("resources", "name");

And in your src/locale/en_CA/resources.properties file:

windowTitle=Window Title
name=Name
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!