Locale data All the data that is required by a framework/application/API in order to be able to honor various cultural conventions in a specific language and region. The data consist of month and day names, date patterns, decimal and thousand separators for number formatting, rules for language specific sorting, info on the measurement system used, and so on. The exact type of data each system chooses to store differs between systems.
Locale In the context of this document, locale refers to the language, script, and region for which an operating system has a collection of locale data as described above. The identification of a locale can be further tailored using variants and keywords. See Locale ID below.
Locale Identifier A string that identifies a locale. In the context of this specification, locale identifiers use the syntax defined in Unicode Technical Standard #35, Unicode Locale Data Markup Language (LDML). In this syntax a locale identifier consists of several sub-tags, that specify the language, script, region, variants, and key value pairs. E.g. the locale identifier for Germany using the German language and sorting by the phonebook sort order is: de-DE@collation=phonebook. Note that not all sub-tags are required; in this case the script is inferred from the language.
flash.globalization A new package added to Flash player version 10.1 to access locale-specific functionality provided by the operating system on which the Flash Player is running.
This Spark Sort & SortField creation is a part of integration of the flash.globalization package with the Flex SDK. (The entire integration process includes the addition of new classes and updates in some existing classes. Such examples are: Spark NumberFormatter, CurrencyFormatter, DateTimeFormatter, MatchingCollator, SortingCollator, StringTools, NumberValidator and CurrencyValidator.)
The existing MX Sort and SortField classes use a compare function for strings that is based on the Unicode code values and does not take into account ordering rules that are language specific. Thus for most languages, the current behavior is incorrect. This specification proposes the creation of new Sort and SortField classes in the Spark namespace that use the language specific string comparison method from the flash.globalization.Collator class by default. In the flash.globalization.Collator class, the language to be used for string comparison is specified by a LocaleID. The new Spark Sort and SortField classes will follow the precedent set by the spark.formatters and spark.globalization classes use the locale style to specify the LocaleID.
A primary use of these new classes is for comparison in the columns of DataGrid components and classes that implement the mx.collections.ICollectionView. To allow interchangeability between the MX Sort and SortField classes, interfaces will be defined and then both the MX and Spark Sort and SortField classes will implement these interfaces.
The new Spark DataGrid component, will use these new Spark Sort and SortField classes by default.
The new Spark Sort & SortField will have almost same API signatures with the existing MX counterparts. The notable points are:
Following is the proposed Sort & SortField interfaces. They are simply extracted from the existing MX Sort & SortField classes and the behavior will be the same with the current MX versions. However, SortField.caseInsensitive is not included in the interface. For the Spark SortField class, this attribute is controlled by a property of the Spark Collator. The existing MX SortField class will continue to have a caseInsensitive property.
package mx.collections { // Proposed ISortField interface. // The existing MX and the new Spark SortField classes implement this interface. // The MX version has all of those functions already. public interface ISort { //-------------------------------------------------------------------------- // Properties //-------------------------------------------------------------------------- function get compareFunction():Function; function set compareFunction(value:Function):void; function get fields():Array; function set fields(value:Array):void; function get unique():Boolean; function set unique(value:Boolean):void; //-------------------------------------------------------------------------- // Functions //-------------------------------------------------------------------------- function findItem( items:Array, values:Object, mode:String, returnInsertionIndex:Boolean = false, compareFunction:Function = null):int; function propertyAffectsSort(property:String):Boolean; function reverse():void; function sort(items:Array):void; } // Proposed ISortField interface. // The existing MX and the new Spark SortField will implement this interface. // The MX version has all of those functions already plus caseInsensitive:Boolean property. public interface ISortField { //-------------------------------------------------------------------------- // Properties //-------------------------------------------------------------------------- function get compareFunction():Function; function set compareFunction(c:Function):void; function get descending():Boolean; function set descending(value:Boolean):void; function get name():String; function set name(n:String):void; function get numeric():Object; function set numeric(value:Object):void; //-------------------------------------------------------------------------- // Functions //-------------------------------------------------------------------------- function reverse():void; //-------------------------------------------------------------------------- // Properties and functions that were used to be mx_internal and now public //-------------------------------------------------------------------------- function get usingCustomCompareFunction():Boolean; function internalCompare(a:Object, b:Object):int; function getArraySortOnOptions():int; function initCompare(obj:Object):void; } }
Update on Nov. 29, 2010
The functions that were used to be mx_internals now have been assigned new names or removed for better clarity as public functions.
Old name
New name
function get usingCustomCompareFunction():Boolean;
(no change)
function internalCompare(a:Object, b:Object):int;
(removed, substituted with other calls.)
function getArraySortOnOptions():int;
function get arraySortOnOptions():int;
function initCompare(obj:Object):void;
function initializeDefaultCompareFunction(obj:Object):void;
Update on Dec. 3, 2010
The new Spark Sort & SortField will have exactly the same API signature with the existing MX counterparts minus SortField.caseInsensitive:Boolean property.
<?xml version="1.0" encoding="utf-8"?> <!-- Simple example to demonstrate the Halo DataGrid control. --> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"> <fx:Declarations> <fx:XMLList id="employees"> <employee> <name>Joanne Wall</name> <phone>555-219-2012</phone> <email>jwall@fictitious.com</email> <active>true</active> </employee> <employee> <name>fr cote</name> <phone>555-219-2000</phone> <email>mjones@fictitious.com</email> <active>true</active> </employee> <employee> <name>Maurice Smith</name> <phone>555-219-2012</phone> <email>maurice@fictitious.com</email> <active>false</active> </employee> <employee> <name>fr côte</name> <phone>555-219-2000</phone> <email>mjones@fictitious.com</email> <active>true</active> </employee> <employee> <name>fr coté</name> <phone>555-219-2000</phone> <email>mjones@fictitious.com</email> <active>true</active> </employee> <employee> <name>fr côté</name> <phone>555-219-2000</phone> <email>mjones@fictitious.com</email> <active>true</active> </employee> <employee> <name>Christina Coenraets</name> <phone>555-219-2270</phone> <email>ccoenraets@fictitious.com</email> <active>true</active> </employee> <employee> <name>Mary Jones</name> <phone>555-219-2000</phone> <email>mjones@fictitious.com</email> <active>true</active> </employee> </fx:XMLList> <s:XMLListCollection id="employees2" source="{employees}"/> </fx:Declarations> <fx:Script> <![CDATA[ import mx.collections.ISort; import mx.collections.ISortField; import mx.collections.Sort; import mx.collections.SortField; import spark.globalization.Sort; import spark.globalization.SortField; import spark.globalization.SortingCollator; <a href="Bindable%28%26quot%3Bchange%26quot%3B%29">Bindable("change")</a> private static var useSparkSort:Boolean = true; <a href="Bindable%28%26quot%3Bchange%26quot%3B%29">Bindable("change")</a> private var collator:SortingCollator = new SortingCollator(); private function sortCompareFunction(a:String, b:String):int { return collator.compare(a, b); } private function sortChange(locale:String):void { const sort:ISort = useSparkSort ? new spark.globalization.Sort() : new mx.collections.Sort(); if (useSparkSort) addStyleClient(sort as spark.globalization.Sort); sort.fields = new Array(); var sf:mx.collections.ISortField; sf = useSparkSort ? new spark.globalization.SortField() : new mx.collections.SortField(); if (useSparkSort) addStyleClient(sf as spark.globalization.SortField); sf.name = "name"; sf.compareFunction = sortCompareFunction; sort.fields.push(sf); employees2.sort = sort; dg.dataProvider = employees2; if (locale) { collator.setStyle("locale", locale); (dg.columns<a href="0">0</a> as DataGridColumn).sortCompareFunction = sortCompareFunction; } else { (dg.columns<a href="0">0</a> as DataGridColumn).sortCompareFunction = null; } } ]]> </fx:Script> <mx:Form> <mx:FormItem label="Locale"> <s:RadioButton label="Use Spark Sort/SortFiled classes" click="useSparkSort=true" selected="{useSparkSort}"/> <s:RadioButton label="Use MX Sort/SortFiled classes" click="useSparkSort=false" selected="{useSparkSort}"/> </mx:FormItem> <mx:FormItem label="Locale"> <s:Button label="Sort: No Collator" click="sortChange(null)"/> <s:Button label="Sort: Collator with 'en' locale" click="sortChange('en')"/> <s:Button label="Sort: Collator with 'fr' locale" click="sortChange('fr')"/> </mx:FormItem> <mx:FormItem label="DataGrid"> <mx:Text text="Select a row in the DataGrid control."/> <mx:DataGrid id="dg" width="100%" height="100%" rowCount="10" dataProvider="{employees2}"> <mx:columns> <mx:DataGridColumn dataField="name" headerText="Name"/> <mx:DataGridColumn dataField="phone" headerText="Phone"/> <mx:DataGridColumn dataField="email" headerText="Email"/> </mx:columns> </mx:DataGrid> </mx:FormItem> <mx:FormItem label="Selected Item"> <mx:Form> <mx:FormItem label="Name"> <mx:Label text="{dg.selectedItem.name}"/> </mx:FormItem> <mx:FormItem label="Email"> <mx:Label text="{dg.selectedItem.email}"/> </mx:FormItem> <mx:FormItem label="Phone"> <mx:Label text="{dg.selectedItem.phone}"/> </mx:FormItem> </mx:Form> </mx:FormItem> </mx:Form> </s:Application>
A prototype was made based on the current specification.
None.
None.
Dependent on several of the support classes that were created when implementing the spark validator classes. The dependent classes are:
None.
None.
None.
However, the new Spark SortField will not have caseInsensitive:Boolean property compare to the existing MX counterpart. Also the new Spark Sort & SortField classes will extend AdvancedStyleClient class as opposed to EventDispatcher class, which the existing MX versions extend.
None.
None.
None.
None.
None. Some existing error messages in Flex SDK are used.
The flash.globalization classes provide different results depending on the platform. Therefore this feature will require testing on different platforms, to ensure that these platform differences are handled properly. If there is a platform that does not support the flash.globalization classes, then testing should also include that platform. The testing should also include setting locales that are not supported on the specific device. This will ensure that the fallback behavior is working correctly.
None.