ECMAScript Globalization APIs in action

This prototype provides a reference implementation for the ECMAScript Globalization API for Internet Explorer.

API Settings

LocaleList

Add
Requested Tags (Clear) :
en-US, en-UK

Some of the sample tags you can choose from :
  • th-TH-u-ca-buddhist-nu-arab : Thai spoken in Thailand with buddihist calandar and arab numbering system
  • ta-IN-u-nu-tamldec : Tamil spoken in India with Tamil numbering system

Collator

Numeric
Ignore Punctuation

NumberFormat




Use Grouping

DateTimeFormat

Hour12


Apply Settings

                                                                                                                                                                                                                                                                                              
Load Data : English | Spanish | French | Arab | Chinese

Apply NF Apply DTF

Effective Locale :

Crop production index (1999-2010)

(Data from : World Bank)

Note: Before you type in some inputs to test, ensure you have set your desired settings in the panel on the left and have clicked "Apply Settings".

                                                                                                                                                                                                                                                                                              

Collator Testing :

Browser locale : None
Requested options : None
Resolved options   : None

Sort




Compare

and are-

Search

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

(You can paste locale specific content and try your search)

Search keyword :

NumberFormat Testing :

Browser locale : None
Requested options : None
Resolved options   : None



DateTimeFormat Testing :

Browser locale : None
Requested options : None
Resolved options   : None

Test Date: , Hours Mins


                                                                                                                                                                                                                                                                                              

Reference documents

A super quick introduction to the APIs

Globalization is the namespace that consists of the following objects.

  1. LocaleList

    You can specify the list of locales in priority order which will be resolved based on the availability. For e.g. if you request en-US and en-GB, if the OS supports en-US, the same will become the active locale or en-GB will be checked. The default is the browser's current locale.

  2. Collator

    Takes the LocaleList object as an argument. You can do either sort or search

  3. NumberFormat

    Takes the LocaleList object as an argument. You can format the number as decimal, currency or percentage

  4. DateTimeFormat

    Takes the LocaleList object as an argument. You can format the dates into various formats (y/d/m or yy/dd/mm etc.) and request for the calendars (gregorian, islamic or buddhist etc.) supported

Sample code

		// Construct locale list which is the first step
		var ll = new Intl.LocaleList(["en-US", "en-GB", "en-IN"]);

		// Construct collator object and do some sorting
		var co = new Intl.Collator(ll);
		var arr = ["z", "b", "a"];
		arr.sort( function(a,b){ 
			return co.compare(a,b)
		});

		// Construct NumberFormat object and format a number
		var nf = new Intl.NumberFormat(ll, {style: "percent"});
		nf.format(100.11); // Prints 100%

		// Construct DateTimeFormat object and format a date
		var nf = new Intl.DateTimeFormat(ll);
		dtf.format();
							

Report bugs to

  • SureshJa@microsoft.com
  • JSi18nDisc@microsoft.com
Loading...
Working ...