Comparing version 0.0.1 to 0.0.2
145
lib/Cldr.js
@@ -9,2 +9,3 @@ var Path = require('path'), | ||
normalizeLocaleId = require('./normalizeLocaleId'), | ||
convertObjectsWithIntegerKeysToArrays = require('./convertObjectsWithIntegerKeysToArrays'), | ||
cldrPluralRuleToJavaScriptAst = require('./cldrPluralRuleToJavaScriptAst'), | ||
@@ -49,3 +50,12 @@ CldrRbnfRuleSet = require('./CldrRbnfRuleSet'), | ||
this.fileNamesByTypeAndNormalizedLocaleId[type] = {}; | ||
fs.readdirSync(Path.resolve(this.cldrPath, "common", type)).forEach(function (fileName) { | ||
var fileNames; | ||
try { | ||
fileNames = fs.readdirSync(Path.resolve(this.cldrPath, "common", type)); | ||
} catch (e) { | ||
if (e.code === 'ENOENT') { | ||
// Directory doesn't exist, just pretend it's empty. | ||
return; | ||
} | ||
} | ||
fileNames.forEach(function (fileName) { | ||
var matchFileName = fileName.match(/^(.*)\.xml$/); | ||
@@ -59,12 +69,2 @@ if (matchFileName) { | ||
this.numberSystemIds = []; | ||
this.getDocument(Path.resolve(this.cldrPath, 'common', 'bcp47', 'number.xml')).find('/ldmlBCP47/keyword/key[@name="nu"]/type').forEach(function (keyNode) { | ||
this.numberSystemIds.push(keyNode.attr('name').value()); | ||
}, this); | ||
this.calendarIds = []; | ||
this.getDocument(Path.resolve(this.cldrPath, 'common', 'bcp47', 'calendar.xml')).find('/ldmlBCP47/keyword/key[@name="ca"]/type').forEach(function (keyNode) { | ||
this.calendarIds.push(keyNode.attr('name').value()); | ||
}, this); | ||
this.localeIds = Object.keys(this.fileNamesByTypeAndNormalizedLocaleId.main); | ||
@@ -75,2 +75,22 @@ this.memoizerByFileName = {}; | ||
Cldr.prototype = { | ||
get calendarIds() { | ||
if (!this._calendarIds) { | ||
this._calendarIds = []; | ||
this.getDocument(Path.resolve(this.cldrPath, 'common', 'bcp47', 'calendar.xml')).find('/ldmlBCP47/keyword/key[@name="ca"]/type').forEach(function (keyNode) { | ||
this._calendarIds.push(keyNode.attr('name').value()); | ||
}, this); | ||
} | ||
return this._calendarIds; | ||
}, | ||
get numberSystemIds() { | ||
if (!this._numberSystemIds) { | ||
this._numberSystemIds = []; | ||
this.getDocument(Path.resolve(this.cldrPath, 'common', 'bcp47', 'number.xml')).find('/ldmlBCP47/keyword/key[@name="nu"]/type').forEach(function (keyNode) { | ||
this._numberSystemIds.push(keyNode.attr('name').value()); | ||
}, this); | ||
} | ||
return this._numberSystemIds; | ||
}, | ||
// Works both async and sync (omit cb): | ||
@@ -162,3 +182,3 @@ getDocument: function (fileName, cb) { | ||
if (aliasNodes.length > 0) { | ||
var aliasSpecifiedQuery = normalizeXPathQuery(aliasNodes[0].path() + '/../' + aliasNodes[0].attr('path').value() + '/' + poppedQueryFragments.join('/')); | ||
var aliasSpecifiedQuery = normalizeXPathQuery(queryFragments.join('/') + '/' + aliasNodes[0].attr('path').value() + '/' + poppedQueryFragments.join('/')); | ||
Array.prototype.push.apply(prioritizedResults, finder(aliasSpecifiedQuery)); | ||
@@ -285,2 +305,3 @@ break; | ||
extractEraNames: function (localeId, calendarId) { | ||
calendarId = calendarId || 'gregorian'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
@@ -297,38 +318,45 @@ eraNames; | ||
}); | ||
return eraNames; | ||
return convertObjectsWithIntegerKeysToArrays(eraNames); | ||
}, | ||
extractQuarterNames: function (localeId, calendarId) { | ||
calendarId = calendarId || 'gregorian'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
quarterNames; | ||
['format', 'stand-alone'].forEach(function (quarterContext) { | ||
var quarterContextCamelCase = quarterContext.replace(/-([a-z])/g, function ($0, ch) { // stand-alone => standAlone | ||
return ch.toUpperCase(); | ||
}); | ||
['abbreviated', 'narrow', 'wide'].forEach(function (quarterWidth) { | ||
finder("/ldml/dates/calendars/calendar[@type='" + calendarId + "']/quarters/quarterContext[@type='" + quarterContext + "']/quarterWidth[@type='" + quarterWidth + "']/quarter").forEach(function (quarterNode) { | ||
// Avoid dashes in width and context (so that dot notation can be used in JavaScript) | ||
var context = quarterContext.replace(/-/g, ''), | ||
width = quarterWidth.replace(/-/g, ''), | ||
quarterNo = parseInt(quarterNode.attr('type').value(), 10) - 1; | ||
var quarterNo = parseInt(quarterNode.attr('type').value(), 10) - 1; | ||
quarterNames = quarterNames || {}; | ||
quarterNames[context] = quarterNames[context] || {}; | ||
quarterNames[context][width] = quarterNames[context][width] || {}; | ||
quarterNames[context][width][quarterNo] = quarterNames[context][width][quarterNo] || quarterNode.text(); | ||
quarterNames[quarterContextCamelCase] = quarterNames[quarterContextCamelCase] || {}; | ||
quarterNames[quarterContextCamelCase][quarterWidth] = quarterNames[quarterContextCamelCase][quarterWidth] || {}; | ||
quarterNames[quarterContextCamelCase][quarterWidth][quarterNo] = quarterNames[quarterContextCamelCase][quarterWidth][quarterNo] || quarterNode.text(); | ||
}); | ||
}); | ||
}); | ||
return quarterNames; | ||
return convertObjectsWithIntegerKeysToArrays(quarterNames); | ||
}, | ||
extractDayPeriods: function (localeId, calendarId) { | ||
calendarId = calendarId || 'gregorian'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
dayPeriods; | ||
['format', 'stand-alone'].forEach(function (dayPeriodContext) { | ||
var dayPeriodContextCamelCase = dayPeriodContext.replace(/-([a-z])/g, function ($0, ch) { // stand-alone => standAlone | ||
return ch.toUpperCase(); | ||
}); | ||
['abbreviated', 'narrow', 'wide', 'short'].forEach(function (dayPeriodWidth) { | ||
finder("/ldml/dates/calendars/calendar[@type='" + calendarId + "']/dayPeriods/dayPeriodContext[@type='" + dayPeriodContext + "']/dayPeriodWidth[@type='" + dayPeriodWidth + "']/dayPeriod").forEach(function (dayPeriodNode) { | ||
var width = dayPeriodWidth.replace(/-/g, ''), | ||
context = dayPeriodContext.replace(/-/g, ''), | ||
type = dayPeriodNode.attr('type').value(); | ||
var type = dayPeriodNode.attr('type').value(); | ||
dayPeriods = dayPeriods || {}; | ||
dayPeriods[context] = dayPeriods[context] || {}; | ||
dayPeriods[context][width] = dayPeriods[context][width] || {}; | ||
dayPeriods[context][width][type] = dayPeriods[context][width][type] || dayPeriodNode.text(); | ||
dayPeriods[dayPeriodContextCamelCase] = dayPeriods[dayPeriodContextCamelCase] || {}; | ||
dayPeriods[dayPeriodContextCamelCase][dayPeriodWidth] = | ||
dayPeriods[dayPeriodContextCamelCase][dayPeriodWidth] || {}; | ||
dayPeriods[dayPeriodContextCamelCase][dayPeriodWidth][type] = | ||
dayPeriods[dayPeriodContextCamelCase][dayPeriodWidth][type] || dayPeriodNode.text(); | ||
}); | ||
@@ -341,2 +369,3 @@ }); | ||
extractCyclicNames: function (localeId, calendarId) { | ||
calendarId = calendarId || 'gregorian'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
@@ -358,39 +387,44 @@ cyclicNames; | ||
}); | ||
return cyclicNames; | ||
return convertObjectsWithIntegerKeysToArrays(cyclicNames); | ||
}, | ||
extractMonthNames: function (localeId, calendarId) { | ||
calendarId = calendarId || 'gregorian'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
monthNames; | ||
['format', 'stand-alone'].forEach(function (monthContext) { | ||
var monthContextCamelCase = dayContext.replace(/-([a-z])/g, function ($0, ch) { // stand-alone => standAlone | ||
return ch.toUpperCase(); | ||
}); | ||
['abbreviated', 'narrow', 'wide'].forEach(function (monthWidth) { | ||
finder("/ldml/dates/calendars/calendar[@type='" + calendarId + "']/months/monthContext[@type='" + monthContext + "']/monthWidth[@type='" + monthWidth + "']/month").forEach(function (monthNode) { | ||
// Avoid dashes in width and context (so that dot notation can be used in JavaScript) | ||
var context = monthContext.replace(/-/g, ''), | ||
width = monthWidth.replace(/-/g, ''); | ||
var monthNo = parseInt(monthNode.attr('type').value(), 10) - 1; | ||
monthNames = monthNames || {}; | ||
monthNames[context] = monthNames[context] || {}; | ||
monthNames[context][width] = monthNames[context][width] || {}; | ||
var monthNo = parseInt(monthNode.attr('type').value(), 10) - 1; | ||
monthNames[context][width][monthNo] = monthNames[context][width][monthNo] || monthNode.text(); | ||
monthNames[monthContextCamelCase] = monthNames[monthContextCamelCase] || {}; | ||
monthNames[monthContextCamelCase][monthWidth] = monthNames[monthContextCamelCase][monthWidth] || {}; | ||
monthNames[monthContextCamelCase][monthWidth][monthNo] = | ||
monthNames[monthContextCamelCase][monthWidth][monthNo] || monthNode.text(); | ||
}); | ||
}); | ||
}); | ||
return monthNames; | ||
return convertObjectsWithIntegerKeysToArrays(monthNames); | ||
}, | ||
extractMonthPatterns: function (localeId, calendarId) { | ||
calendarId = calendarId || 'gregorian'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
monthPatterns; | ||
['format', 'numeric', 'stand-alone'].forEach(function (monthPatternContext) { | ||
var monthPatternContextCamelCase = monthPatternContext.replace(/-([a-z])/g, function ($0, ch) { // stand-alone => standAlone | ||
return ch.toUpperCase(); | ||
}); | ||
['abbreviated', 'narrow', 'wide', 'all'].forEach(function (monthPatternWidth) { | ||
finder("/ldml/dates/calendars/calendar[@type='" + calendarId + "']/monthPatterns/monthPatternContext[@type='" + monthPatternContext + "']/monthPatternWidth[@type='" + monthPatternWidth + "']/monthPattern").forEach(function (monthPatternNode) { | ||
// Avoid dashes in width and context (so that dot notation can be used in JavaScript) | ||
var type = monthPatternNode.attr('type').value(), | ||
width = monthPatternWidth.replace(/-/g, ''), | ||
context = monthPatternContext.replace(/-/g, ''); | ||
var type = monthPatternNode.attr('type').value(); | ||
monthPatterns = monthPatterns || {}; | ||
monthPatterns[context] = monthPatterns[context] || {}; | ||
monthPatterns[context][width] = monthPatterns[context][width] || {}; | ||
monthPatterns[context][width][type] = monthPatterns[context][width][type] || monthPatternNode.text(); | ||
monthPatterns[monthPatternContextCamelCase] = monthPatterns[monthPatternContextCamelCase] || {}; | ||
monthPatterns[monthPatternContextCamelCase][monthPatternWidth] = | ||
monthPatterns[monthPatternContextCamelCase][monthPatternWidth] || {}; | ||
monthPatterns[monthPatternContextCamelCase][monthPatternWidth][type] = | ||
monthPatterns[monthPatternContextCamelCase][monthPatternWidth][type] || monthPatternNode.text(); | ||
}); | ||
@@ -403,2 +437,3 @@ }); | ||
extractDayNames: function (localeId, calendarId) { | ||
calendarId = calendarId || 'gregorian'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
@@ -408,18 +443,20 @@ dayNoByCldrId = {sun: 0, mon: 1, tue: 2, wed: 3, thu: 4, fri: 5, sat: 6}, | ||
['format', 'numeric', 'stand-alone'].forEach(function (dayContext) { | ||
var dayContextCamelCase = dayContext.replace(/-([a-z])/g, function ($0, ch) { // stand-alone => standAlone | ||
return ch.toUpperCase(); | ||
}); | ||
['abbreviated', 'narrow', 'wide', 'short'].forEach(function (dayWidth) { | ||
finder("/ldml/dates/calendars/calendar[@type='" + calendarId + "']/days/dayContext[@type='" + dayContext + "']/dayWidth[@type='" + dayWidth + "']/day").forEach(function (dayNode) { | ||
var width = dayWidth.replace(/-/g, ''), | ||
context = dayContext.replace(/-/g, ''), | ||
dayNo = dayNoByCldrId[dayNode.attr('type').value()]; | ||
var dayNo = dayNoByCldrId[dayNode.attr('type').value()]; | ||
dayNames = dayNames || {}; | ||
dayNames[context] = dayNames[context] || {}; | ||
dayNames[context][width] = dayNames[context][width] || {}; | ||
dayNames[context][width][dayNo] = dayNames[context][width][dayNo] || dayNode.text(); | ||
dayNames[dayContextCamelCase] = dayNames[dayContextCamelCase] || {}; | ||
dayNames[dayContextCamelCase][dayWidth] = dayNames[dayContextCamelCase][dayWidth] || {}; | ||
dayNames[dayContextCamelCase][dayWidth][dayNo] = dayNames[dayContextCamelCase][dayWidth][dayNo] || dayNode.text(); | ||
}); | ||
}); | ||
}); | ||
return dayNames; | ||
return convertObjectsWithIntegerKeysToArrays(dayNames); | ||
}, | ||
extractFields: function (localeId, calendarId) { | ||
calendarId = calendarId || 'gregorian'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
@@ -447,2 +484,3 @@ fields; | ||
extractDateTimePatterns: function (localeId, calendarId) { | ||
calendarId = calendarId || 'gregorian'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
@@ -463,2 +501,3 @@ dateTimePatterns; | ||
extractDateOrTimeFormats: function (localeId, calendarId, dateOrTime) { | ||
calendarId = calendarId || 'gregorian'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
@@ -483,2 +522,3 @@ formats; | ||
extractDateFormatItems: function (localeId, calendarId) { | ||
calendarId = calendarId || 'gregorian'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
@@ -495,2 +535,3 @@ dateFormatItems; | ||
extractDefaultDateTimePatternName: function (localeId, calendarId) { | ||
calendarId = calendarId || 'gregorian'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
@@ -505,2 +546,3 @@ defaultDateTimePatternName; | ||
extractDateIntervalFormats: function (localeId, calendarId) { | ||
calendarId = calendarId || 'gregorian'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
@@ -527,2 +569,3 @@ dateIntervalFormats; | ||
extractDateIntervalFallbackFormat: function (localeId, calendarId) { | ||
calendarId = calendarId || 'gregorian'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
@@ -539,2 +582,3 @@ dateIntervalFallbackFormat; | ||
extractNumberSymbols: function (localeId, numberSystemId) { | ||
numberSystemId = numberSystemId || 'latn'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
@@ -551,2 +595,3 @@ numberSymbols; | ||
extractNumberFormats: function (localeId, numberSystemId) { | ||
numberSystemId = numberSystemId || 'latn'; | ||
var finder = this.createFinder(this.getPrioritizedDocumentsForLocale(localeId, 'main')), | ||
@@ -553,0 +598,0 @@ numberFormats; |
@@ -25,5 +25,12 @@ var _ = require('underscore'); | ||
function ruleToExpressionAst(rule) { | ||
var expressionAsts = []; | ||
var expressionAsts = [], | ||
rbnf = rule.rbnf; | ||
rule.rbnf.replace(/(?:([\<\>\=])(?:(%%?[\w\-]+)|([#,0.]+))?\1)|(?:\[([^\]]+)\])|([\x7f-\uffff:'\.\s\w\d\-]+)/gi, function ($0, specialChar, otherFormat, decimalFormat, optional, literal) { | ||
// "If a rule body begins with an apostrophe, the apostrophe is ignored, but all text after it becomes | ||
// significant (this is how you can have a rule's rule text begin with whitespace)." | ||
// -- http://www.icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html | ||
rbnf = rbnf.replace(/^'/, ''); | ||
// Replace is used for tokenization, the return value isn't used: | ||
rbnf.replace(/(?:([\<\>\=])(?:(%%?[\w\-]+)|([#,0.]+))?\1)|(?:\[([^\]]+)\])|([\x7f-\uffff:'\.\s\w\d\-]+)/gi, function ($0, specialChar, otherFormat, decimalFormat, optional, literal) { | ||
// The meanings of the substitution token characters are as follows: | ||
@@ -30,0 +37,0 @@ if (specialChar) { |
{ | ||
"name": "cldr", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Library for extracting data from CLDR (the Unicode Common Locale Data Repository)", | ||
@@ -19,2 +19,6 @@ "main": "lib/Cldr.js", | ||
}, | ||
"devDependencies": { | ||
"expect.js": "=0.2.0", | ||
"mocha": "=1.7.0" | ||
}, | ||
"keywords": [ | ||
@@ -21,0 +25,0 @@ "locale", |
207
README.md
@@ -11,3 +11,3 @@ cldr | ||
* Number formats, symbols, and digits for all number systems | ||
* Exemplar and elipisis characters | ||
* Exemplar and ellipsis characters | ||
* Day names, month names, quarter names, era names, and cyclic names | ||
@@ -27,2 +27,4 @@ * Patterns for rendering lists of items | ||
Tested with CLDR releases 22 and 22.1. | ||
Usage | ||
@@ -34,8 +36,10 @@ ===== | ||
$ npm install cldr | ||
``` | ||
$ npm install cldr | ||
``` | ||
Next up you need to download a <a | ||
href="http://cldr.unicode.org/index/downloads">CLDR release</a> or | ||
checkout the <a href="http://unicode.org/repos/cldr/">Subversion | ||
repo</a>. | ||
href="http://cldr.unicode.org/index/downloads">CLDR release</a> (look | ||
for `core.zip`) or checkout the <a | ||
href="http://unicode.org/repos/cldr/">Subversion repo</a>. | ||
@@ -66,17 +70,64 @@ Now you're ready to create a node-cldr instance and take it for a | ||
Properties | ||
========== | ||
### cldr.localeIds ### | ||
An array of locale ids for which data is available (656 in CLDR | ||
release 22.1). The locale ids are "normalized" to be all lower case | ||
with underscores separating the fragments. However, all methods that | ||
take a locale id as a parameter will accept any casing and both `-` | ||
and `_` as separators. | ||
### cldr.calendarIds ### | ||
An array of calendar ids for which data is available. In CLDR release | ||
22.1: | ||
```javascript | ||
[ 'buddhist', 'chinese', 'coptic', 'dangi', 'ethioaa', 'ethiopic', | ||
'gregory', 'hebrew', 'indian', 'islamic','islamicc', 'iso8601', | ||
'japanese', 'persian', 'roc' ] | ||
``` | ||
### cldr.numberSystemIds ### | ||
An array of number system ids for which data is available. In CLDR | ||
release 22.1: | ||
```javascript | ||
[ 'arab', 'arabext', 'armn', 'armnlow', 'bali', 'beng', 'brah', | ||
'cakm', 'cham', 'deva', 'ethi', 'finance', 'fullwide', 'geor', | ||
'grek', 'greklow', 'gujr', 'guru', 'hanidec', 'hans', 'hansfin', | ||
'hant', 'hantfin', 'hebr', 'java', 'jpan', 'jpanfin', 'kali', | ||
'khmr', 'knda', 'lana', 'lanatham', 'laoo', 'latn', 'lepc', | ||
'limb', 'mlym', 'mong', 'mtei', 'mymr', 'mymrshan', 'native', | ||
'nkoo', 'olck', 'orya', 'osma', 'roman', 'romanlow', 'saur', | ||
'shrd', 'sora', 'sund', 'takr', 'talu', 'taml', 'tamldec', | ||
'telu', 'thai', 'tibt', 'traditio', 'vaii' ] | ||
``` | ||
Methods | ||
======= | ||
cldr.extractLanguageDisplayNames(localeId) | ||
------------------------------------------ | ||
All the data extraction methods are synchronous, which means that XML | ||
documents that haven't already been loaded will be loaded using | ||
`fs.readFileSync`. The reasoning behind this is that the API would be | ||
awkward if all the extraction methods had to take callbacks. Also, | ||
`node-cldr` is unlikely to be used in a setting where performance is | ||
critical. However, if for some reason you want to avoid the | ||
synchronous loads, you can use `cldr.load(<arrayOfLocaleIds>, cb)` to | ||
load all the needed data in parallel before starting the extraction | ||
itself. Then all the needed documents will be loaded and ready. | ||
### cldr.extractLanguageDisplayNames(localeId='root') ### | ||
Extract a locale ID => display name hash for a locale: | ||
```javascript | ||
cldr.extractLanguageDisplayNames('it').en | ||
cldr.extractLanguageDisplayNames('it').en; | ||
'inglese' | ||
``` | ||
cldr.extractTimeZoneDisplayNames(localeId) | ||
------------------------------------------ | ||
### cldr.extractTimeZoneDisplayNames(localeId='root') ### | ||
@@ -86,8 +137,7 @@ Extract a time zone ID (Olson) => display name hash for a locale: | ||
```javascript | ||
cldr.extractLanguageDisplayNames('it')['Europe/Gibraltar'] | ||
cldr.extractTimeZoneDisplayNames('it')['Europe/Gibraltar']; | ||
'Gibilterra' | ||
``` | ||
cldr.extractTimeZoneFormats(localeId) | ||
------------------------------------- | ||
### cldr.extractTimeZoneFormats(localeId='root') ### | ||
@@ -107,4 +157,3 @@ Extract a hash with ICU formats for displaying information about a | ||
cldr.extractTerritoryDisplayNames(localeId) | ||
------------------------------------------- | ||
### cldr.extractTerritoryDisplayNames(localeId='root') ### | ||
@@ -118,4 +167,3 @@ Extract a territory ID => display name hash for a locale: | ||
cldr.extractCurrencyInfoById(localeId) | ||
-------------------------------------- | ||
### cldr.extractCurrencyInfoById(localeId='root') ### | ||
@@ -133,4 +181,3 @@ Extract hash with currency ID keys mapping to currency info objects | ||
cldr.extractScriptDisplayNames(localeId) | ||
---------------------------------------- | ||
### cldr.extractScriptDisplayNames(localeId='root') ### | ||
@@ -140,8 +187,7 @@ Extract a script ID => display name hash for a locale: | ||
```javascript | ||
cldr.extractScriptDisplayNames('en_US').Arab | ||
cldr.extractScriptDisplayNames('en_US').Arab; | ||
'Arabic' | ||
``` | ||
cldr.extractEraNames(localeId, calendarId) | ||
------------------------------------------ | ||
### cldr.extractEraNames(localeId='root', calendarId='gregorian') ### | ||
@@ -161,4 +207,3 @@ Extract a nested hash with era names in `wide` and `abbreviated` | ||
cldr.extractQuarterNames(localeId, calendarId) | ||
---------------------------------------------- | ||
### cldr.extractQuarterNames(localeId='root', calendarId='gregorian') ### | ||
@@ -179,4 +224,3 @@ Extract a nested hash with quarter names in various formats for a calendar and locale: | ||
cldr.extractDayPeriods(localeId, calendarId) | ||
-------------------------------------------- | ||
### cldr.extractDayPeriods(localeId='root', calendarId='gregorian') ### | ||
@@ -198,4 +242,3 @@ Extract a nested hash with day periods in various formats for a | ||
cldr.extractCyclicNames(localeId, calendarId) | ||
--------------------------------------------- | ||
### cldr.extractCyclicNames(localeId='root', calendarId='gregorian') ### | ||
@@ -210,4 +253,3 @@ Extract a nested hash with cyclic names for a calendar and locale | ||
cldr.extractMonthNames(localeId, calendarId) | ||
-------------------------------------------- | ||
### cldr.extractMonthNames(localeId='root', calendarId='gregorian') ### | ||
@@ -223,4 +265,3 @@ Extract a nested hash with month names (in various contexts) for a | ||
cldr.extractMonthPatterns(localeId, calendarId) | ||
----------------------------------------------- | ||
### cldr.extractMonthPatterns(localeId='root', calendarId='gregorian') ### | ||
@@ -243,4 +284,3 @@ Extract a nested hash with month patterns (in various contexts) for a | ||
cldr.extractDayNames(localeId, calendarId) | ||
------------------------------------------ | ||
### cldr.extractDayNames(localeId='root', calendarId='gregorian') ### | ||
@@ -261,4 +301,3 @@ Extract a nested hash with day names (in various contexts) for a | ||
cldr.extractFields(localeId, calendarId) | ||
---------------------------------------- | ||
### cldr.extractFields(localeId='root', calendarId='gregorian') ### | ||
@@ -269,3 +308,3 @@ Extract a nested hash with display names (including relative) for | ||
```javascript | ||
cldr.extractFields('en', 'gregorian').month | ||
cldr.extractFields('en', 'gregorian').month; | ||
{ displayName: 'Month', | ||
@@ -278,4 +317,3 @@ relative: | ||
cldr.extractDateTimePatterns(localeId, calendarId) | ||
-------------------------------------------------- | ||
### cldr.extractDateTimePatterns(localeId='root', calendarId='gregorian') ### | ||
@@ -287,3 +325,3 @@ Extract a hash with ICU patterns that show how to build a date-time | ||
```javascript | ||
cldr.extractDateTimePatterns('en', 'gregorian') | ||
cldr.extractDateTimePatterns('en', 'gregorian'); | ||
{ full: '{1} \'at\' {0}', | ||
@@ -295,4 +333,3 @@ long: '{1} \'at\' {0}', | ||
cldr.extractDateFormats(localeId, calendarId) | ||
--------------------------------------------- | ||
### cldr.extractDateFormats(localeId='root', calendarId='gregorian') ### | ||
@@ -302,3 +339,3 @@ Extract a hash of basic date formats (ICU) for a calendar and locale: | ||
```javascript | ||
cldr.extractDateFormats('en_GB', 'gregorian') | ||
cldr.extractDateFormats('en_GB', 'gregorian'); | ||
{ full: 'EEEE, d MMMM y', | ||
@@ -310,4 +347,3 @@ long: 'd MMMM y', | ||
cldr.extractTimeFormats(localeId, calendarId) | ||
--------------------------------------------- | ||
### cldr.extractTimeFormats(localeId='root', calendarId='gregorian') ### | ||
@@ -318,3 +354,3 @@ Extract a hash of basic time formats (ICU) for a given calendar and | ||
```javascript | ||
cldr.extractTimeFormats('en_GB', 'gregorian') | ||
cldr.extractTimeFormats('en_GB', 'gregorian'); | ||
{ full: 'HH:mm:ss zzzz', | ||
@@ -326,7 +362,8 @@ long: 'HH:mm:ss z', | ||
cldr.extractDateFormatItems(localeId, calendarId, dateOrTime) | ||
------------------------------------------------------------- | ||
### cldr.extractDateFormatItems(localeId='root', calendarId='gregorian') ### | ||
Extract a hash of date formats (ICU) for displaying dates and times | ||
at various detail levels for a calendar and locale: | ||
Extract a hash of <a | ||
href="http://www.unicode.org/reports/tr35/tr35-29.html#Date_Format_Patterns">ICU | ||
date formats</a> for displaying dates and times at various detail | ||
levels for a calendar and locale: | ||
@@ -346,4 +383,3 @@ ```javascript | ||
cldr.extractDefaultDateTimePatternName(localeId, calendarId) | ||
------------------------------------------------------------ | ||
### cldr.extractDefaultDateTimePatternName(localeId='root', calendarId='gregorian') ### | ||
@@ -357,4 +393,3 @@ Extract the name of the default date time pattern for a locale and calendar: | ||
cldr.extractDateIntervalFormats(localeId, calendarId) | ||
----------------------------------------------------- | ||
### cldr.extractDateIntervalFormats(localeId='root', calendarId='gregorian') ### | ||
@@ -381,4 +416,3 @@ Extract a nested hash with date interval display formats (ICU), keyed | ||
cldr.extractDateIntervalFallbackFormat(localeId, calendarId) | ||
------------------------------------------------------------ | ||
### cldr.extractDateIntervalFallbackFormat(localeId='root', calendarId='gregorian') ### | ||
@@ -390,8 +424,7 @@ Extract the date interval fallback format (ICU) for a given calendar | ||
```javascript | ||
cldr.extractDateIntervalFallbackFormat('en_GB', 'gregorian') | ||
cldr.extractDateIntervalFallbackFormat('en_GB', 'gregorian'); | ||
'{0} – {1}' | ||
``` | ||
cldr.extractNumberSymbols(localeId, numberSystemId) | ||
--------------------------------------------------- | ||
### cldr.extractNumberSymbols(localeId='root', numberSystemId='latn') ### | ||
@@ -414,6 +447,7 @@ Extract the number symbols for a given number system and locale: | ||
cldr.extractNumberFormats(localeId, numberSystemId) | ||
--------------------------------------------------- | ||
### cldr.extractNumberFormats(localeId='root', numberSystemId='latn) ### | ||
Extract the number formats for a given number system and locale: | ||
Extract the number formats (<a | ||
href="http://www.unicode.org/reports/tr35/tr35-29.html#Number_Format_Patterns">ICU | ||
DecimalFormat</a>) for a given number system and locale: | ||
@@ -439,4 +473,3 @@ ```javascript | ||
cldr.extractDefaultNumberSystemId(localeId) | ||
------------------------------------------- | ||
### cldr.extractDefaultNumberSystemId(localeId='root') ### | ||
@@ -446,10 +479,9 @@ Extract the id of the default number system for a locale: | ||
```javascript | ||
cldr.extractDefaultNumberSystemId('en_GB') | ||
cldr.extractDefaultNumberSystemId('en_GB'); | ||
'latn' | ||
cldr.extractDefaultNumberSystemId('ar') | ||
cldr.extractDefaultNumberSystemId('ar'); | ||
'arab' | ||
``` | ||
cldr.extractUnitPatterns(localeId) | ||
---------------------------------- | ||
### cldr.extractUnitPatterns(localeId='root') ### | ||
@@ -459,3 +491,3 @@ Extract the unit patterns (ICU) for a locale (to be used with a plural rule function): | ||
```javascript | ||
cldr.extractUnitPatterns('en_GB') | ||
cldr.extractUnitPatterns('en_GB'); | ||
{ day: { one: '{0} day', other: '{0} days' }, | ||
@@ -473,4 +505,3 @@ dayFuture: { one: 'In {0} day', other: 'In {0} days' }, | ||
cldr.extractDelimiters(localeId) | ||
-------------------------------- | ||
### cldr.extractDelimiters(localeId='root') ### | ||
@@ -487,4 +518,3 @@ Extract the delimiters for a locale: | ||
cldr.extractListPatterns(localeId) | ||
---------------------------------- | ||
### cldr.extractListPatterns(localeId='root') ### | ||
@@ -501,6 +531,8 @@ Extract the list patterns (ICU) for a locale: | ||
cldr.extractCharacters(localeId) | ||
-------------------------------- | ||
### cldr.extractCharacters(localeId='root') ### | ||
Extract information about various character classes, ellipsis patterns etc. for a locale: | ||
```javascript | ||
cldr.extractCharacters('en_GB'); | ||
{ exemplar: | ||
@@ -513,5 +545,5 @@ { default: [ 'a', 'b', 'c', 'd', 'e', [...], 'x', 'y', 'z' ], | ||
moreInformation: '?' } | ||
``` | ||
cldr.extractPluralRuleFunction(localeId) | ||
---------------------------------------- | ||
### cldr.extractPluralRuleFunction(localeId='root') ### | ||
@@ -523,3 +555,3 @@ Extract a plural rule function for a locale (See <a | ||
```javascript | ||
cldr.extractPluralRuleFunction('en_GB').toString() | ||
cldr.extractPluralRuleFunction('en_GB').toString(); | ||
function (n) { | ||
@@ -529,3 +561,3 @@ if (n === 1) return "one"; | ||
} | ||
cldr.extractPluralRuleFunction('ar').toString() | ||
cldr.extractPluralRuleFunction('ar').toString(); | ||
function (n) { | ||
@@ -541,4 +573,3 @@ if (n === 0) return "zero"; | ||
cldr.extractRbnfFunctionByType(localeId, types) | ||
----------------------------------------------- | ||
### cldr.extractRbnfFunctionByType(localeId='root'[, types]) ### | ||
@@ -548,6 +579,7 @@ Extracts RBNF (<a | ||
number formatting</a>) functions for a locale. The 'types' parameter | ||
specifies the names of the functions you want, and the returned hash | ||
will contain the ones that were found plus their dependencies. | ||
specifies the names of the functions you want (defaults to all | ||
available), and the returned hash will contain the ones that were | ||
found plus their dependencies. | ||
The original function names have been converted to camelcase and | ||
The original function names have been converted to camelCase and | ||
prefixed with `render`, and you need to use that naming convention | ||
@@ -557,5 +589,5 @@ when specifying the `types` array as well. | ||
```javascript | ||
cldr.extractRbnfFunctionByType('en_GB', ['renderRomanUpper']).renderRomanUpper(2012); | ||
cldr.extractRbnfFunctionByType('en_GB').renderRomanUpper(2012); | ||
'MMXII' | ||
cldr.extractRbnfFunctionByType('de', ['renderSpelloutOrdinal']).renderSpelloutOrdinal(2323); | ||
cldr.extractRbnfFunctionByType('de').renderSpelloutOrdinal(2323); | ||
'zweitausenddreihundertdreiundzwanzigste' | ||
@@ -569,4 +601,3 @@ ``` | ||
cldr.extractDigitsByNumberSystemId() | ||
------------------------------------ | ||
### cldr.extractDigitsByNumberSystemId() ### | ||
@@ -573,0 +604,0 @@ Extract a hash of number system id => digits array. For some exotic |
78206
14
940
584
2