36.0.2 • Published 8 months ago

cldr-data v36.0.2

Weekly downloads
46,373
License
-
Repository
github
Last release
8 months ago

Npm's cldr-data

Npm module for Unicode CLDR JSON data.

Goal

  • Allow i18n libraries to define CLDR data as versioned "peer" dependency.
  • Provide tools to assist (in other words, ease the pain) on fetching the data.

Bonus goals

Usage

For libraries

On the package.json of your i18n library, define its CLDR data dependency by using the peerDependencies property.

"peerDependencies": {
  "cldr-data": ">=26"
}

On your library, access CLDR JSON data using require("cldr-data").

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

  // Your awesome pluralization logic
  pluralForm = doAwesomeStuffWith(
    plurals.supplemental["plurals-type-cardinal"][language]
  );

  return pluralForm;
}

For your convinience, use cldr-data in conjunction with cldr.js. You can find more details switching to the Foo Number Format Library Example or Application Example branches.

For applications

On the package.json of your applications, define its CLDR data dependency by using the dependencies or devDependencies property.

"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.

$ CLDR_COVERAGE=full npm install

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.

{
  ...
  "cldr-data-coverage": "full",
  ...
}

Set Custom json file with urls or filter existing

By default, used file urls.json form cldr-data module, which contain for each locale coverage 18 urls. For set custom .json file, that have structure accoding urls.json use cldr-data-urls-json property in package.json your webApp Define the package.json cldr-data-urls-json property

{
  ...
  "cldr-data-urls-json": "../../cldrdatadwnl.json",
  ...
}

Path must be relative from cldr-data directory

Example custom cldrdatadwnl.json File have only 7 urls.

{
    "core": [
        "https://github.com/unicode-cldr/cldr-core/archive/30.0.3.zip",
        "https://github.com/unicode-cldr/cldr-dates-modern/archive/30.0.3.zip",
        "https://github.com/unicode-cldr/cldr-localenames-modern/archive/30.0.3.zip",
        "https://github.com/unicode-cldr/cldr-misc-modern/archive/30.0.3.zip",
        "https://github.com/unicode-cldr/cldr-numbers-modern/archive/30.0.3.zip",
        "https://github.com/unicode-cldr/cldr-segments-modern/archive/30.0.3.zip",
        "https://github.com/unicode-cldr/cldr-units-modern/archive/30.0.3.zip"
    ]
}

Or you can filter existing urls by regexp pattern, via cldr-data-urls-filter field in package.json:

{
  ...
  "cldr-data-urls-filter": "(cldr-core|cldr-numbers-modern|cldr-dates-modern)",
  ...
}

License

MIT © Rafael Xavier de Souza

36.0.2

8 months ago

36.0.1

3 years ago

36.0.0

5 years ago

35.1.0

6 years ago

35.0.0

6 years ago

34.0.0

6 years ago

33.0.0

6 years ago

31.0.3

7 years ago

30.0.5

7 years ago

29.0.3

7 years ago

32.0.1

7 years ago

32.0.0

7 years ago

31.0.2

8 years ago

31.0.1

8 years ago

31.0.0

8 years ago

30.0.4

8 years ago

30.0.3

8 years ago

30.0.2

8 years ago

30.0.1

8 years ago

30.0.0

8 years ago

29.0.2

8 years ago

28.0.5

8 years ago

27.0.10

8 years ago

26.0.17

8 years ago

25.0.17

8 years ago

29.0.1

9 years ago

28.0.4

9 years ago

27.0.9

9 years ago

26.0.16

9 years ago

25.0.16

9 years ago

29.0.0

9 years ago

28.0.3

9 years ago

28.0.2

9 years ago

27.0.8

9 years ago

26.0.15

9 years ago

25.0.15

9 years ago

28.0.1

9 years ago

27.0.7

9 years ago

26.0.14

9 years ago

25.0.14

9 years ago

28.0.0

9 years ago

27.0.6

9 years ago

26.0.13

9 years ago

25.0.13

9 years ago

27.0.5

10 years ago

26.0.12

10 years ago

25.0.12

10 years ago

25.0.11

10 years ago

27.0.4

10 years ago

26.0.11

10 years ago

25.0.10

10 years ago

27.0.3

10 years ago

27.0.2

10 years ago

27.0.1

10 years ago

27.0.0

10 years ago

26.0.10

10 years ago

25.0.9

10 years ago

25.0.8

10 years ago

26.0.9

10 years ago

25.0.7

10 years ago

26.0.8

10 years ago

26.0.7

10 years ago

26.0.6

10 years ago

25.0.6

10 years ago

25.0.5

10 years ago

26.0.4

10 years ago

25.0.4

10 years ago

26.0.3

10 years ago

25.0.3

10 years ago

25.0.2

10 years ago

26.0.2

10 years ago

26.0.1

10 years ago

25.0.1

10 years ago

25.0.0

10 years ago

26.0.0

10 years ago

0.0.1

10 years ago

0.0.1-alpha.2

10 years ago

0.0.1-alpha.1

10 years ago