Globalization API: Objects needed?

Norbert Lindenberg ecmascript at norbertlindenberg.com
Sun Nov 20 15:23:48 PST 2011


When a caller of the Globalization API requests a locale or parameter combination that's valid but that the implementation doesn't support, then the implementation falls back to something it does support. The resolvedOptions accessor property of the constructed object provides information on what the implementation came up with, so that the caller can decide whether the fallback is acceptable or whether it wants to use alternative solutions.

Examples:

- A caller requests a date format for Spanish in Guatemala, and the implementation doesn't have that. The implementation might fall back to a generic Spanish (probably for Spain), or to the Spanish of big neighbor Mexico, or, if it runs on a budget cell phone designed for India and doesn't have any Spanish, even to Hindi. The caller might decide that any Spanish is OK as long as the month is spelled out (users shouldn't have to guess between day/month and month/day formats), but that Hindi needs to be worked around by loading up another date formatting library that does support Spanish.

- A application for Islamic prayer times requests the Islamic calendar; if the implementation offers Gregorian instead, the application may load a library that does support Islamic.

Norbert


On Nov 20, 2011, at 9:59 , Brendan Eich wrote:

> On Nov 19, 2011, at 7:27 PM, Norbert Lindenberg wrote:
> 
>>>> 2.a. Find out if there were fallbacks through object state
>>> 
>>> That can be done by object-detecting the proto-methods too, right?
>> 
>> I'm not sure what you mean - how would you implement the functionality of Collator.resolveOptions without Collator objects?
> 
> You wouldn't. I understood "fallbacks through object state" to mean testing (typeof Globalization != "undefined" && Globalization.DateTimeFormat) or equivalent, but testing for a prototype-based method can work as well.
> 
> Clearly I misunderstood what "Find out if there were fallbacks through object state" means. Could you give an example?



More information about the es-discuss mailing list