Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Create LocaleList object with well formed list of locales, and save
- // languageMatcher for later.
- var locales = new LocaleList([...], languageMatcher);
- // Create DateTimeFormat object.
- // Use localeMatcher function to match available locales to |locales|. It would
- // also be used for supportedLocalesOf method call.
- // Use dateMatcher function to match options to available pattern.
- var dtf = new DateTimeFormat(locales, options, dateMatcher);
- // Both localeMatcher and dateMatcher are optional.
- // If they are not specified we use default implementation.
- // One of the languageMatcher functions can be 'bcp47' matcher.
- // Implementations can implement them as native or JS code.
- // Users of the library could implement their own.
- /*
- * Other way would be to define matchers in global scope:
- */
- Globalization.languageMatcher = function() {...};
- Globalization.dateTimeMatcher = function() {...};
- // I don't think there are any issues with this approach. Already constructed objects would have already resolved the data.
- // New object would use new matchers (in case one changed the matchers during the lifetime of given context).
Advertisement
Add Comment
Please, Sign In to add comment