I have a Flex application that loads it's locale resource bundle from a service.
So when the httpservice loads the bundle it populates an instance of a class "I18NBundle" that contains all the bundle properties. For instance you could do:
i18nBundle.hello_message and it would return "Hello"
I'm currently using Cairngorm for this project so this i18nBundle instance it's on the model locator.
What I'm seeing and that I don't like is that for a component be able to get the bundle it must access to the model locator and then to the i18nBundle.
Instead of that what I would like is that each component doesn't rely on this for getting the bundle.
I guess I could create a "bundle" property on each component class and then pass it the reference to the bundle when it is instanciated. It seems it could be messy and a difficult task to initialize this property in some cases for instance on a datagrid cell renderer.
Other could be transforming the I18NBundle class into a singleton and then when the service response it's recieved the singleton it's initialized. Since all application components should/must access the same locale bundle I guess this could be a better option.
What do you think about this?
Do you think there is some a better way to achieve this with Flex?
Any opinion or recommendation would be appreciatted.
(I don't wish to use the Adobe Flex proposal of having the properties file on the Flex project and the compiling them into swf.)
thanks in advance.
ps: If you think I haven't expressed myself correctly please let me know and I will rewrite it.
It seems that a nice option would be to make my bundle class implement IResourceBundle.
Then I should add that bundle to the application resource bundle manager i guess.
I have managed to extend IResourceBundle and added it to ResourceManager.
The only problem now is that my bundle does not represent a language and it doesn't need a name either.
Since the localization part is done on the webapplication and then the apporpiate bundle returned in the request's response.
So it's locale attribute value is "".
And it's name is "".
I can display a property correctly if I use the following code:
but I doesn't work if I try to retrieve it like:
any ideas ?