0

In Flash Builder 4.7 (with AIR 3.5) I'm trying to add locales en_US and de_DE to a Flex Mobile app, which originally has been ru_RU only.

I.e. originally I only had -locale ru_RU in Project Properties -> Flex compiler and hardcoded russian text in the source code (everything worked ok).

But after studying the Adobe docs Localization in Flex – Part 1: Compiling resources into an application and Adding new locales I have changed the Flex compiler (flags) to: -locale ru_RU en_US de_DE:

enter image description here

And have added src\locale\{locale} to the Source Path:

enter image description here

Finally I have created the subdirs and files

src\locale\ru_RU\resources.properties
src\locale\en_US\resources.properties
src\locale\de_DE\resources.properties

Here the en_US\resources.properties contents:

menu.play=Play via
menu.weekly=Weekly rating
menu.daily=Daily misere
menu.settings=Settings

The AIR 3.5 SDK dir already contains the 3 subdirs per se:

C:\Program Files\Adobe\Adobe Flash Builder 4.7 (64 Bit)\sdks\4.6.0 (AIR 3.5)\

frameworks\projects\framework\bundles\ru_RU
frameworks\projects\framework\bundles\en_US
frameworks\projects\framework\bundles\de_DE

so I haven't used the copylocale utility (right?)

In my source code I have change the first View:

<fx:Metadata>
    [ResourceBundle("resources")]
</fx:Metadata> 
......

[Bindable]
private var _ac:ArrayCollection = new ArrayCollection([
    { icon: OK_ICON, view: OK, label: resourceManager.getString('resources','menu.play'), msg: 'Odnoklassniki.ru' },
    { icon: MR_ICON, view: MR, label: resourceManager.getString('resources','menu.play'), msg: 'Mail.ru' },
    { icon: VK_ICON, view: VK, label: resourceManager.getString('resources','menu.play'), msg: 'Vk.com' },
    { icon: FB_ICON, view: FB, label: resourceManager.getString('resources','menu.play'), msg: 'Facebook.com' },
    { icon: GG_ICON, view: GG, label: resourceManager.getString('resources','menu.play'), msg: 'Google+' }
]);

However that new code bombs out at the runtime, saying that the resourceManager is null.

What have I missed please?

Should I initialize the resourceManager somehow?

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
  • 1
    Not sure if this was an issue for you, but I found that without defining the compiler argument as `-locale=en_US,ru_RU` the compiler would not recognize the multiple parameters. – Danielle Neri Jun 05 '13 at 14:06

2 Answers2

1

This is just a guess, but it seems to make sense:

You're trying to use the ResourceManager when initializing the ArrayCollection. This sort of variable initialization happens when the class is created, and it's very likely that is not enough time for Flex to do all the things it does w/your view (like initialize it's resourceManager property).

If you populate your ArrayCollection after the view dispatches a "creationComplete" event, then you should be guaranteed that the resourceManager is no longer null. Perhaps you can try some of the other Flex life cycle events that get dispatched before "creationComplete" like "initialize" to do this work a bit sooner...

Sunil D.
  • 17,983
  • 6
  • 53
  • 65
  • That was it, thank you! Moved it to `initialize` stage and now it works. Do I have to update `_ac` manually, when changing locale? I've added a button with `click="resourceManager.localeChain=['de_DE']"` but the `_ac` and the List using it do not update by themselves. – Alexander Farber Jun 01 '13 at 09:21
  • 1
    "Normally", you shouldn't have to do that... It's been too long since I did this, so this may not be correct. I put "normal" in quotes because the simple use case is something like this: `` By binding like this, I believe the resourceManager will dispatch an event to trigger another call to get the string when the language changes. However, in your case the elements of your `ArrayCollection` are just objects (not `EventDispatcher`'s), so the elements in your dataProvider are not listening for binding events and won't know the lang has changed. – Sunil D. Jun 01 '13 at 09:39
  • 1
    You could refactor your list so that the dataProvider contains the resource bundle ID for the string, rather then the string itself. Then in the item renderer, use a binding expression as in my comment above to populate the label in the renderer w/the appropriate string. I'm not sure if this has any performance implications (may impact scrolling performance of the list). – Sunil D. Jun 01 '13 at 09:43
0

your missing the comma in your compiler argument between the locale codes.

if you want to put your locals under your src folder like i do you can add the following compiler arguments.

-locale=en_US,fr_FR,zh_CN,pt_BR -allow-source-path-overlap=true -source-path=locale/{locale}
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335