You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by ScolabAndre <an...@scolab.com> on 2016/10/27 21:02:32 UTC

FlexJS : internationalization with ResourceBundle?

Hi, 

I'm trying to convert a lib to FlexJS. The library is using RessourceManager
with RessourceBundle for internationalization. This feature of Flex is
probably not available, can't find equivalent in org.apache. Does the flexJS
sdk generate JS classes for properties files already and need implementation
for mx.resources.ResourceManager?

Or alternative idea for implementing this feature?
Thank you



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/FlexJS-internationalization-with-ResourceBundle-tp13962.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: FlexJS : internationalization with ResourceBundle?

Posted by Nemi <ne...@gmail.com>.
Maybe it would be great if questions like this and similar will have its web
page at the website, titled like:
"Flex vs FlexJS". So users can quickly found out, at least, more important
changes.



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/FlexJS-internationalization-with-ResourceBundle-tp13962p13967.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: FlexJS : internationalization with ResourceBundle?

Posted by Alex Harui <ah...@adobe.com>.

On 10/28/16, 8:41 AM, "ScolabAndre" <an...@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


Re: FlexJS : internationalization with ResourceBundle?

Posted by ScolabAndre <an...@scolab.com>.
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.



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/FlexJS-internationalization-with-ResourceBundle-tp13962p13969.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: FlexJS : internationalization with ResourceBundle?

Posted by Alex Harui <ah...@adobe.com>.

On 10/27/16, 2:02 PM, "ScolabAndre" <an...@scolab.com> wrote:

>Hi, 
>
>I'm trying to convert a lib to FlexJS. The library is using
>RessourceManager
>with RessourceBundle for internationalization. This feature of Flex is
>probably not available, can't find equivalent in org.apache. Does the
>flexJS
>sdk generate JS classes for properties files already and need
>implementation
>for mx.resources.ResourceManager?
>
>Or alternative idea for implementing this feature?

We haven't taken on resource bundles in FlexJS yet.  Some questions:

1) Are all of your resources strings and/or numbers?  Or are there bitmaps
and other objects? 
2) Do you want to compile in the resource bundles or load them at runtime?

IMO, for non-object resources, the pay-as-you-go principle would have the
properties file either compile into a JSON object or load and parse the
actual properties file as a string.  Resource modules would essentially be
a network fetch of a JSON or text response.

The mx.resources.ResourceManager was way more robust than you need for
just strings and numbers.  For many scenarios the amount of code that
downloaded and ran in order to just return strings and numbers was way
more than actually embedding the .properties files and parsing them
on-demand.

Another thing to note is that Flex has a way of supporting non-standard
CSS properties.  FlexJS already uses it to specify certain default beads.
It is possible to leverage that and/or org.apache.flex.core.ValuesManager
to get some locale-dependent strings in your app relatively quickly.  A
custom valuesImpl in the application could subclass SimpleCSSValuesImpl
and override getValue and return strings.  If you want to try to create
such a thing, feel free to ask more questions and we'll help you out.

Thanks,
-Alex