Skip to content
This repository has been archived by the owner on Nov 26, 2022. It is now read-only.

Question and Answers

ThomasBurleson edited this page Sep 14, 2010 · 18 revisions

1) How do I use external, compiled resource bundles with l10nInjection?
When I embed my localized resource bundles into the application, my application startup time is too long. How can I use external resources bundles?

Answer:
Localized resources bundles can be huge; especially when you embed fonts and images. Embedding the bundles means your application footprint is huge and thus the startup time is excessive. In such cases, developers should consider using external resource bundles (compiled into .swf files). And if you are embedding fonts, you should also consider specifying Unicode font-ranges in your css. [Non-roman languages such as Chinese, Japanese, etc. display words using glyphs; glyph sets can be 5-20 Mbytes in size…]

The l10nInjection has a new feature that makes using external bundles trivial: ExternalLocaleCommand!

See the l10nInjection Sample FlexStore Revisited which uses a new l10n class called ExternalLocaleCommand in a Command Factory pattern [see lines 74-80]. The LocalizationMap (on lineauto-instantiates an instance of that factory class and uses it to auto-load the resource bundles asynchronously from externally compiled resource bundles. Line 77 shows how developers can provide custom path options to the ExternalLocaleCommand processing.

2) Can l10nInjection be used without ResourceBundles?
Can the LocalizationMap and the IoC principles described here be used WITHOUT ResourceBundles? My localized strings (only strings) come from a database backend (not a bundle), but I’d still like to use the injection mechanism.

Answer:
If you want to load your localized strings from a remote text file of a database backend – instead of using embedded or external, compiled bundles – simply create a new LocaleCommand subclass and use that as the generator instead of ExternalLocaleCommand.

For example, DatabaseLocaleCommand [which should extend LocaleCommand] could make either a HTTPService or RemoteObject async call to load the remote information from your database. Once the RPC call responds, build an in-memory resource bundle and then update the ResourceManager with the new locale chain. This last action of changing the locale chaing will then auto-trigger the LocalizationMap to run and inject your latest localized strings.

Clone this wiki locally