flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: FlexJS : internationalization with ResourceBundle?
Date Fri, 28 Oct 2016 22:01:31 GMT


On 10/28/16, 8:41 AM, "ScolabAndre" <andrelacasse@scolab.com> wrote:

>The majority of ressources are properties files for translation and some
>XML
>files. For the moment, it's for test purpose only so the simplest solution
>will be fine. The goal is to have a lib working in Flash (SWC) and JS for
>the migration process.
>
>With the conditional compiling, I can implement a differents pattern for
>JS.
>

Is your code using @resource in MXML or calls to ResourceManager?

I just realized that FlexJS compiler output for SWF probably won't output
the bundles.  There are different code paths in the compiler.  So a simple
cross-platform solution is probably needed.

One way that should work today is to convert your properties files to CSS
class selectors.  IOW, where your properties file contained:

#--en_US/mybundle.properties
resourceID1=Enter Name:
resourceID2=Enter Password

You would convert that to CSS

.en_US_mybundle {
 -resourceID1: "Enter Name:";
 -resourceID2: "Enter Password:";
}

Then an override of SimpleCSSValuesImpl could have getValues check for a
string in the thisObject which would be the clue it is a resource fetch.
If the string passed in is the locale and bundle name, you could look up
the value and return it.  A bit of a hack, but on the other hand it
doesn't require another subsystem in the app.

A more sophisticated implementation might want to embed an entire
properties file as the value of a String variable.  Then code could parse
that and return values as needed.  I just pushed changes to allow
embedding of strings as follows:

[Embed(source="core.properties",mimeType="text/plain")]	
	public var en_US_Core:String;

It should be in the nightly build in a couple of hours.  If you are
interested in pursuing this angle, we should probably move this discussion
to the dev@ list.

HTH,

-Alex

Mime
View raw message