That's very clever.

Gordon's suggestion of adding [Bindable]  metadata to the buildTitle()
method and overriding resourcesChanged() works nicely, and I could
imagine caching some strings in the override, but adding the override
in numerous components is a bit of a nuisance, so your idea is quite
appealing.

Thanks!

On Fri, Jun 20, 2008 at 7:53 PM, brent80301 <[EMAIL PROTECTED]> wrote:
> A trick that I have used in this case (when overriding
> resourcesChanged is inconvenient) is to add a property to your
> whatever.properties file that has no value but accepts a parameter
> like the following.
>
> eval = {0}
>
> Then, in your mxml component, do something like the following.
>
> <mx:Label
> text="{resourceManager.getString('whatever','eval',[buildTitle(someParameter)])}"/>
>
> This will reevaluate when the locale is changed, and the eval property
> will simply pass through the new value. Voila!
>
> -Brent
>
> --- In [email protected], "Richard Rodseth" <[EMAIL PROTECTED]> 
> wrote:
>>
>> No, no, I am definitely using the ResourceManager. But the expression
>> is something like
>>
>> text="{buildTitle(someParameter)}"
>>
>> And buildTitle calls static function getUIString which calls
>> getResourceManager followed by some string substitution.
>>
>> On Fri, Jun 20, 2008 at 2:59 PM, Gordon Smith <[EMAIL PROTECTED]> wrote:
>> > If you're not using MXML databinding to write code like
>> >
>> >
>> >
>> > <Button id="b" label="{resourceManager.getString(...)}"/>
>> >
>> >
>> >
>> > then you can override the resourcesChanged() method and reassign
> the new
>> > string, as in
>> >
>> >
>> >
>> > b.label = resourceManager.getString(...);
>> >
>> >
>> >
>> > The ResourceManager works with resources in ResourceBundles, which
> normally
>> > get compiled from .properties files. Are you loading .properties
> files at
>> > runtime and parsing them yourself to get keys and values? In that
> case, you
>> > can create new instances of ResourceBundle at runtime, put your
> resources
>> > into them, and install them into the ResourceManager like this:
>> >
>> >
>> >
>> > var rb:ResourceBundle = new ResourceBundle(locale, bundleName);
>> >
>> > rb.content[key1] = value1;
>> >
>> > rb.content[key2] = value2;
>> >
>> > ...
>> >
>> > resourceManager.addResourceBundle(rb);
>> >
>> >
>> >
>> > Gordon Smith
>> >
>> > Adobe Flex SDK Team
>> >
>> >
>> >
>> > ________________________________
>> >
>> > From: [email protected]
> [mailto:[EMAIL PROTECTED] On
>> > Behalf Of Richard Rodseth
>> > Sent: Friday, June 20, 2008 2:37 PM
>> > To: [email protected]
>> > Subject: Re: [flexcoders] internationalization @ switching runtime
>> >
>> >
>> >
>> > Gordon,
>> >
>> > Forgive me (or ignore this) if it's in the docs.
>> >
>> > Does this assume that the ResourceManager.getString call is in the
>> > binding expression?
>> > Currently I have some static utilities that load strings like "Hello,
>> > {0}" from properties files and then do parameter substitution. I've
>> > been wondering how that would work out in a runtime locale switching
>> > scenario.
>> >
>> > On Fri, Jun 20, 2008 at 2:14 PM, Gordon Smith <[EMAIL PROTECTED]> wrote:
>> >> You want to learn about the ResourceManager class in Flex 3. It
> allows you
>> >> to simply change its localeChain property at runtime and have the
> entire
>> >> application redraw in a new language.
>> >>
>> >>
>> >>
>> >> Gordon Smith
>> >>
>> >> Adobe Flex SDK Team
>> >>
>> >>
>> >>
>> >> ________________________________
>> >>
>> >> From: [email protected]
> [mailto:[EMAIL PROTECTED] On
>> >> Behalf Of artur_desig2dev
>> >> Sent: Friday, June 20, 2008 6:12 AM
>> >> To: [email protected]
>> >> Subject: [flexcoders] internationalization @ switching runtime
>> >>
>> >>
>> >>
>> >> forgive my newbie question..
>> >>
>> >> just wanted to find out the best practice on this to date.
>> >> on how to change all the components' language at runtime.
>> >>
>> >> i found 2 methods of doing this:
>> >>
>> >> http://flexme.wordpress.com/2007/07/11/internationalization-in-flex/
>> >>
>> >> http://www.herrodius.com/blog/123
>> >> http://flexme.wordpress.com/2007/07/11/internationalization-in-flex/
>> >>
>> >> thanks
>> >>
>> >>
>> >
>> >
>>
>
> 

Reply via email to