0 Replies Latest reply on Jul 3, 2008 3:16 PM by (GordonSmith)

    [svn] 2366: Minor Enhancement SDK-15573: Locale sorting.

    Level 1
      Revision: 2366
      Author: gosmith@adobe.com
      Date: 2008-07-03 16:16:15 -0700 (Thu, 03 Jul 2008)

      Log Message:
      -----------
      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

      resourceManager.localeChain = resourceManager.getPreferredLocaleChain()

      to set the localeChain to an intelligently-sorted list (the locales for which resources are available, sorted by what the user prefers to see).

      Bugs: SDK-15573
      QA: Yes!
      Doc: Yes

      Ticket Links:
      ------------
      http://bugs.adobe.com/jira/browse/SDK-15573
      http://bugs.adobe.com/jira/browse/SDK-15573

      Modified Paths:
      --------------
      flex/sdk/branches/3.1.0/frameworks/projects/framework/src/mx/core/FlexModuleFactory.as
      flex/sdk/branches/3.1.0/frameworks/projects/framework/src/mx/managers/SystemManager.as
      flex/sdk/branches/3.1.0/frameworks/projects/framework/src/mx/resources/IResourceManager.a s
      flex/sdk/branches/3.1.0/frameworks/projects/framework/src/mx/resources/ResourceManagerImp l.as

      Added Paths:
      -----------
      flex/sdk/branches/3.1.0/frameworks/projects/framework/src/mx/resources/LocaleSorter.as