Description
openedon Jan 19, 2018
It can be said that the challenge of providing i18n services can be split into two concepts:
- Data: One needs access to a database of locale data.
- Logic: Once the data is provided, there needs to be a way to process it.
In the i18n world, as well as in software in general, people like to be able to design their own logic. There are already dozens of wrappers over Ecma 402. It is not hard to find examples of clients who reverse-engineer i18n libraries to "extract" the data out of them; I can provide some examples.
Right now, the Ecma 402 APIs are all "logic" APIs. I suggest that we consider breaking the APIs into the two concepts: data and logic. The existing APIs need not change; I suggest simply adding a new data API, and redefining the spec for the logic functions to be in terms of the data. The data format can be defined by the Unicode specification UTS 35, which is supported by another standards body.
The advantages of doing this include:
- Clients can write their own i18n logic on top of Ecma 402's data, without needing to reverse-engineer the built-in logic APIs.
- We can make it easy for clients to swap in their own data source to replace the Ecma 402 data.
- The specs can be more clear, since the logic API can be a relatively straightforward definition on top of the data API, and the data API can refer to parts of UTS 35.
The API can be as simple as something like Intl.Data.getNumberPattern(locale)
or Intl.Data.getDateTimePattern(locale, skeleton)
. The methods can return a promise or take a callback to allow the user to make an asynchronous pop-in replacement.