Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cldr-data

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cldr-data - npm Package Compare versions

Comparing version 26.0.10 to 26.0.11

85

index.js

@@ -11,13 +11,68 @@ /**

var MAIN_FILES = ["ca-buddhist", "ca-chinese", "ca-coptic", "ca-dangi",
"ca-ethiopic-amete-alem", "ca-ethiopic", "ca-generic", "ca-gregorian",
"ca-hebrew", "ca-indian", "ca-islamic-civil", "ca-islamic", "ca-islamic-rgsa",
"ca-islamic-tbla", "ca-islamic-umalqura", "ca-japanese", "ca-persian", "ca-roc",
"characters", "currencies", "dateFields", "delimiters", "languages", "layout",
"listPatterns", "localeDisplayNames", "measurementSystemNames", "numbers",
"posix", "scripts", "territories", "timeZoneNames", "units", "variants"
];
var SUPPLEMENTAL_FILES = ["aliases", "calendarData", "calendarPreferenceData",
"characterFallbacks", "codeMappings", "currencyData", "gender",
"languageData", "languageMatching", "likelySubtags", "measurementData",
"metaZones", "numberingSystems", "ordinals", "parentLocales", "plurals",
"postalCodeData", "primaryZones", "references", "telephoneCodeData",
"territoryContainment", "territoryInfo", "timeData", "weekData",
"windowsZones"
];
var assert = require("assert");
var _path = require("path");
function cldrData(path) {
function argsToArray(arg) {
return [].slice.call(arg, 0);
}
function flatten(obj) {
var arr = [];
function _flatten(obj, arr) {
if(Array.isArray(obj)) {
return obj.forEach(function(obj) {
_flatten(obj, arr);
});
}
arr.push(obj);
}
_flatten(obj, arr);
return arr;
}
function cldrData(path/*, ...*/) {
assert(typeof path === "string", "must include path (e.g., " +
"\"main/en/numbers\" or \"supplemental/likelySubtags\")");
path = _path.join("json", path);
if (arguments.length > 1) {
return argsToArray(arguments).reduce(function(sum, path) {
sum.push(cldrData(path));
return sum;
}, []);
}
return require("./" + path);
}
function mainPathsFor(locales) {
return locales.reduce(function(sum, locale) {
MAIN_FILES.forEach(function(mainFile) {
sum.push(_path.join("main", locale, mainFile));
});
return sum;
}, []);
}
function supplementalPaths() {
return SUPPLEMENTAL_FILES.map(function(supplementalFile) {
return _path.join("supplemental", supplementalFile);
});
}
Object.defineProperty(cldrData, "availableLocales", {

@@ -29,21 +84,17 @@ get: function() {

cldrData.forEachMain = function(callback) {
assert(typeof callback === "function", "must include callback function");
cldrData.all = function() {
var paths = supplementalPaths().concat(mainPathsFor(this.availableLocales));
return cldrData.apply({}, paths);
}
cldrData.availableLocales.forEach(function(locale) {
callback(function(path) {
return cldrData(_path.join("main", locale, path));
});
});
};
cldrData.entireMainFor = function(locale/*, ...*/) {
assert(typeof locale === "string", "must include locale (e.g., " +
"\"en\")");
return cldrData.apply({}, mainPathsFor(argsToArray(arguments)));
}
cldrData.main = function(path) {
assert(typeof path === "string", "must include path (e.g., " +
"\"numbers\" or \"ca-gregorian\")");
return cldrData.availableLocales.map(function(locale) {
return cldrData(_path.join("main", locale, path));
});
cldrData.entireSupplemental = function() {
return cldrData.apply({}, supplementalPaths());
}
module.exports = cldrData;

4

package.json
{
"name": "cldr-data",
"version": "26.0.10",
"version": "26.0.11",
"keywords": [

@@ -33,3 +33,3 @@ "unicode",

"dependencies": {
"cldr-data-downloader": "0.1.x"
"cldr-data-downloader": "0.2.x"
},

@@ -36,0 +36,0 @@ "devDependencies": {

@@ -21,5 +21,7 @@ # Npm's cldr-data

On the `package.json` of your i18n library, define its CLDR data dependency.
compatible with.
### For libraries
On the `package.json` of your i18n library, define its CLDR data dependency by
using the *peerDependencies* property.
"peerDependencies": {

@@ -32,6 +34,4 @@ "cldr-data": ">=26"

```javascript
cldr = require("cldr-data");
function Pluralize(locale) {
var plurals = cldr("supplemental/plurals");
var plurals = require("cldr-data/supplemental/plurals");
var language = extractLanguageFrom(locale);

@@ -56,9 +56,22 @@

### Locale coverage
### For applications
By default, the locale coverage installed is `core`, which Unicode defines as
the top tier languages and is equivalent to the `json.zip` content. There exists two solutions to get the full coverage: either by setting the environmental variable `CLDR_COVERAGE` to `full` or define the coverage in your `package.json`.
On the `package.json` of your applications, define its CLDR data dependency by
using the *dependencies* or *devDependencies*property.
#### Environmental variable
In this example we are installing `cldr-data` by setting the `CLDR_COVERAGE` to `full`:
"dependencies": {
"cldr-data": "26",
"libraries-that-use-cldr-data": "x"
}
#### Locale coverage
By default, the locale coverage installed is **core**, which Unicode defines as
the top tier languages and is equivalent to the `json.zip` content. There are
two ways to modify the installation and get the **full** coverage instead.
*Use the environment variable `CLDR_COVERAGE`*
On the command line, set the locale coverage using the environment variable.
```

@@ -68,4 +81,7 @@ $ CLDR_COVERAGE=full npm install

#### package.json
Define your coverage by setting the property `cldr-data-coverage` in your `package.json:
*Use the package.json `cldr-data-coverage` property*
On the `package.json` of you application, set the locale coverage using the
`cldr-data-coverage` property.
```

@@ -72,0 +88,0 @@ {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc