Minor Enhancement SDK-15573: Locale sorting.
Applied and modified the patch that was provided. Thank you, Romania team!
This enhancement affects the default localeChain at startup when you don't specify it in an HTML wrapper. The localeChain is now sorted based on the system's preferred locales, as determined from the Capabilities.languages and Capabilities.language APIs.
For example, suppose an app has been compiled with -locale=en_US,fr_FR,de_DE. Before this enhancement, the default localeChain would be [ "en_US", "fr_FR", "de_DE" ] regardless of the system you were running on. But now, if Capabilities.languages reports that the system's preferred locales are [ "fr-CA", "de" ], the localeChain will be [ "fr_FR", "de_DE", "en_US" ], with the result that the French resources are used rather than the English ones.
The module factory classes SystemManager and FlexModuleFactory, which initialize the localeChain if it hasn't been set by the HTML wrapper, used to simply set the localeChain to the list of compiled locales. They now use a new IResourceManager method, initializeLocaleChain() to set the localeChain in a more intelligent way, passing the list of compiled locales to this method. It in turn determines the list of the system's preferred locales and passes the two lists to a new utility method, LocaleSorter.sortLocalesByPreference(). This returns the first list sorted according to the second list, and the result gets assigned as the localeChain. (Note: The LocaleSorter class will not be documented.)
In addition, IResourceManager has a new getPreferredLocaleChain() method. It is similar to getLocales() but sorts the locale list based on the system's preferred localse. After loading resource modules or adding ResourceBundles into the ResourceManager, you can do