User:Waldo/Internationalization API: Difference between revisions

Jump to navigation Jump to search
More info
(Add more details)
(More info)
Line 9: Line 9:
== Internationalization in SpiderMonkey ==
== Internationalization in SpiderMonkey ==


SpiderMonkey includes significant support for the Internationalization API.  The fundamental primitives used to implement the API are provided by an in-tree imported copy of ICU in {{source|intl/icu}}.  This is an optional component of a SpiderMonkey build; support may be turned on using the <code>--enable-intl-api</code> configuration option.  The Internationalization API is enabled by default in Firefox builds.  Features and capabilities of the API itself are implemented in both C++ and in self-hosted JavaScript that accesses ICU functionality through various intrinsic functions in the self-hosting global.
SpiderMonkey includes significant support for the Internationalization API.  The fundamental primitives used to implement the API are provided by an in-tree imported copy of ICU.  This is an optional component of a SpiderMonkey build; support may be turned on using the <code>--enable-intl-api</code> configuration option.  Most of SpiderMonkey's Internationalization code gets built even when the API is disabled, but the <code>Intl</code> object isn't added to global objects, and the legacy <code>toLocale*String</code> methods are implemented using SpiderMonkey's old <code>JSLocaleCallbacks</code> interface.  Features and capabilities of the Internationalization API itself are implemented in both C++ and in self-hosted JavaScript that accesses ICU functionality through various intrinsic functions in the self-hosting global.
 
The Internationalization API is enabled by default in SpiderMonkey when embedded in Firefox builds.


=== Code organization ===
=== Code organization ===
Line 15: Line 17:
==== ICU ====
==== ICU ====


International Components for Unicode is a library implementing collation, formatting, and other locale-sensitive functions.  It provides the underlying functionality used in implementing Internationalization.
International Components for Unicode is a library implementing collation, formatting, and other locale-sensitive functions.  It provides the underlying functionality used in implementing Internationalization. ICU is imported in {{source|intl/icu}}


==== Integration ====
==== Integration ====
Line 34: Line 36:


All the constructor functions are implemented in C++ in {{source|js/src/builtin/Intl.cpp}}.  These need to call into enough C++ code to create the necessary ICU data structures for it to be worth keeping them in C++.
All the constructor functions are implemented in C++ in {{source|js/src/builtin/Intl.cpp}}.  These need to call into enough C++ code to create the necessary ICU data structures for it to be worth keeping them in C++.
==== Tests ====
Tests live in {{source|js/src/tests/test402}}, an unmodified import of the ECMA-402 test suite.  '''XXX Explain how the tests are run, how they're skipped in no-<code>Intl</code> builds, how to update them, how to contribute to them, how we disable/annotate any tests we don't pass'''


=== Key concepts ===
=== Key concepts ===


 
...talk about collators, date formats, and how all the stuff is implemented using what ICU primitives...


=== Known bugs and issues ===
=== Known bugs and issues ===
Line 43: Line 49:
ECMA-402 says that the supported numbering systems for a locale are (unsurprisingly) locale-dependent.  ICU exposes the default numbering system for a locale via a C++ API, but otherwise it pretends any numbering system can be used by any locale.  Thus SpiderMonkey's implementation says that the default numbering system is supported (obviously), and it says a handful of common decimal numbering systems are supported.  See <code>getNumberingSystems</code> in {{source|js/src/builtin/Intl.cpp}}.  If ICU ever provides more comprehensive information here, we should probably use it.
ECMA-402 says that the supported numbering systems for a locale are (unsurprisingly) locale-dependent.  ICU exposes the default numbering system for a locale via a C++ API, but otherwise it pretends any numbering system can be used by any locale.  Thus SpiderMonkey's implementation says that the default numbering system is supported (obviously), and it says a handful of common decimal numbering systems are supported.  See <code>getNumberingSystems</code> in {{source|js/src/builtin/Intl.cpp}}.  If ICU ever provides more comprehensive information here, we should probably use it.


The ICU interface that exposes a locale's default numbering system (see above) is C++, which (see below) means it's not stable.  There's an [http://bugs.icu-project.org/trac/ticket/10039 issue] on file to add a C API for this.
The ICU interface that exposes a locale's default numbering system (see above) is C++, which (see below) means it's not stable.  There's an [http://bugs.icu-project.org/trac/ticket/10039 issue] on file to add a C API for this.  Until that's implemented and we use it, be careful about ICU upgrades.


=== Other random details ===
=== Other random details ===
Confirmed users
446

edits

Navigation menu