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
:
And have added src\locale\{locale}
to the Source Path:
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?
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...