3

According to the Adobe asdocs, Flex framework files are supposed to be able to be loaded at runtime. These localized framework files, the ones that exist at (on windows) C:\Program Files (x86)\Adobe\Adobe Flash Builder 4.5\sdks\4.5.0\frameworks\locale, are responsible for items such as button text on Alert Dialogs, and a host of other controls. My expectation is that once these framework files are loaded I would see these resources available in my Flex app.

I've set up my project as follows:

MyProject
   -src
   -Flex4.5
   -Referenced Libraries
   -bin-debug
   -bin-release
   -libs
   -locale (I've copied all of the directories(da_DK,en_US,es_ES,etc) of framework files for the locales I want to support inside of this dir)

Now the asdocs state that in order to do this, you have to set the compiler settings to read

-locale=en_US,da_DK,de_DE,es_ES,fi_FI,fr_FR,it_IT,ja_JP,ko_KR,nb_NO,nl_NL,pt_BR,ru_RU,sv_SE,zh_CN,zh_TW -allow-source-path-overlap=true -source-path=locale/{locale}

which I have done.

My Build Path Libraries for Flex 4.5 - C:Program Files (x86)\Adobe\Adobe Flash Builder 4.5\sdks\4.5.0 are set to be Runtime Shared library (of note, the {locale} subfolder says "Merged into code")

But when I change the language in the browser, I'm not seeing any of the framework resources.

Also, when I build my project, I don't see any indication of the locale-oriented resource files in the bin-release. Since we only deploy the contents of the bin-release folder (and not the entire project), how is this supposed to work?

I am also seeing .swz files in my bin-release (and I know these arent the localized framework resources).

Does anyone have any experience with Runtime Framework Localization?? What am I doing wrong? My expectation is that once I build my project (with the framework resources externalized) that the app would be able to load those resources, but this isn't happening and I am not interested in compiling a different version of my app for all of the locales I support.

Thanks in advance

Shawn
  • 2,406
  • 1
  • 26
  • 31
  • PS: a step by step example or other tutorial would be helpful rather than just posting a link to the asdocs. Thanks :) – Shawn Jun 08 '11 at 15:31
  • What are you trying to do? What do you expect to happen with this? – J_A_X Jun 08 '11 at 15:37
  • I want my app to load the Localized Framework Files at runtime based upon the locale that is consuming them. I handle the locale inside my app and would expect that setting the locale chain (onPreInit) and then calling it onInit would allow things like dates, OK, Cancel, etc to be consumed by my project per locale. For example, if the user has a system or browser setting that calls for Mandarin, I expect to see the OK and Cancel in the Alert Dialog display in Mandarin, same with Calendars, etc etc. To me, this would make sense for loading Localized Framework Resources at runtime. – Shawn Jun 08 '11 at 20:30

1 Answers1

0

I use the following ANT task which works for me:

<mxmlc file="${build.dir.src}/${mxml.file}" keep-generated-actionscript="false" output="${build.dir.stage}/${project.app.name}.swf" 
        actionscript-file-encoding="UTF-8" incremental="false" context-root="${project.app.name}" optimize="${app.optimize}"
        debug="${app.debug}" configname="air" locale="en_US,ja_JP,fr_FR">

<jvmarg value="-Xmx1024m" />
<jvmarg value="-Xms512m" />

<compiler.theme append="true" file="${FLEX_HOME}/frameworks/projects/spark/MXFTEText.css" />

<source-path path-element="${FLEX_HOME}/frameworks" />
<source-path path-element="${build.dir.locale.src}/{locale}" />

<library-path dir="${FLEX_HOME}/frameworks/libs" append="true">
    <include name="*.swc" />
</library-path>
<library-path dir="${FLEX_HOME}/frameworks/libs/air" append="true">
    <include name="*.swc" />
</library-path>
<library-path dir="${FLEX_HOME}/frameworks/locale" append="true">
    <include name="{locale}" />
</library-path>
<library-path dir="${build.dir.lib}" append="true">
    <include name="*.swc" />
</library-path>

Add the following tag to the classes that use resources and read the strings in the way:

[ResourceBundle('application')]

// set up the locale chain
ResourceManager.getInstance().localeChain = [ 'en_US', 'ja_JP', 'fr_FR' ];

// load resources
ResourceManager.getInstance().getString('application', 'some.string.code');

An observation: One does not need to copy the framework files into one's project folder. They will be picked up the compiler when compiling.

Let me know if it works, else we can debug more!

sangupta
  • 2,396
  • 3
  • 23
  • 37
  • Im a little confused about your last comment Sandy. If I deploy my project to a server other than my development box, and I'm using runtime loading of framework files, how are they going to be able to be accessed if they arent copied? – Shawn Jun 20 '11 at 12:41
  • Hi Shawn - I did not mean that you would not need to deploy the files... surely you would. Only during the compilation process, you need not copy the framework libraries into your project folder. This is similar (opposite though) to (if you are familiar with the JAVA world) copying and using Tomcat's servlet-api.jar during compilation, but not packaging it during the WAR generation. – sangupta Jul 19 '11 at 16:28