royale-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Idylog - Nicolas Granon" <ngra...@idylog.com>
Subject RE: Struggling with resource files
Date Sun, 01 Oct 2017 11:42:45 GMT
Hi Harbs,

"I’m not sure if a default resource bundle should be included at compile time as well."

Well, it seems to me that, in Flex, there must be a default bundle (cooked inside the swf)
that is used by the framework itself for a number of tasks :
Standard validators, standard formatters, default button label (ok, cancel...), default loader
label (loading ...%) and, in a general manner, all "standard" texts and value come from there.

The default locale is any of the locales defined in the frameworks/locale folder or the selected
sdk.

Maybe it is not necessary to cook that default locale inside the compile js but I cannot imagine
there is no default locale at all..??
(if the default locale is not cooked inside the base js, we must manage the case where it
fails to load...)

As for the PAYG way, it seems to me that if we have ResourceBundle and ResourceManager it
is acceptable to load resources (any resource!) at run time, and at any time. Or maybe I did
not correctly understand your concerns ?


"I’m actually not really sure how resource bundles are compiled and used in classic Flex."

"Compiled" resources are really nothing more than an object whose property name are the .properties
file keys and the values are the values from the .properties (might be indirect in case of
binary values).

Resource bundle can even be created at runtime (we use this a lot : it allows us to have resources
containing values that depend on user login).

Maybe I can help about this. What exactly is unclear to you ?

Nicolas Granon




> -----Message d'origine-----
> De : Harbs [mailto:harbs.lists@gmail.com]
> Envoyé : dimanche 1 octobre 2017 11:41
> À : dev@royale.apache.org
> Objet : Struggling with resource files
> 
> I’m trying to figure out an elegant way to use resource bundles in a
> PAYG way and I’m having trouble.
> 
> I’m actually not really sure how resource bundles are compiled and used
> in classic Flex.
> 
> As I see it, there’s three cases where resource bundles might be used:
> 
> 1. The locale is known at compile time.
> 2. The locale is known at app initialization.
> 3. The locale might be changed during runtime.
> 
> The ResourceManager classes in classic Flex is designed with #3 in mind
> and it’s not very PAYG at all.
> 
> I’d venture to say that the biggest use case is #1. #2 is relatively
> common as well. #3 is probably pretty rare.
> 
> For case #2, it’s probably necessary to load the resource bundles as
> separate HTTP request(s) once the app initializes. I’m not sure if a
> default resource bundle should be included at compile time as well.
> Dunno.
> 
> Case #1 seem the most straight-forward and there really should be some
> way to specify resources when compiling an app.
> 
> I just committed some code which takes a stab at compile time resource
> strings, but it’s kind of hacky, and I feel like there’s a better way
> to go about it. Ideally, there should be some way to specify and
> .properties file and have it included in the app.
> 
> To use what I committed you’d do something like this (not tested and
> probably not working, but I wanted to commit the general idea):
> 
> <js:CurrencyValidator>
>   <js:beads>
>     <js:SimpleResourceStringBead
> resources=“org.apache.flex.utils.validation.resources.creditcard.en_us”
> />
>   </js:beads>
> </js:CurrencyValidator>
> 
> Any ideas on how to better go about this?
> 
> Harbs


Mime
View raw message