-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLDR data as versioned “peer” dependency #18
Comments
I've implemented a proof of concept for the "npm (custom fetch)" approach: https://gist.github.com/rxaviers/87e089c35d46fd3a1492. The script fetches an initial url (e.g., Conclusion, the content crawling is pretty quick. Although, making multiple requests to crawl and fetch the above content takes way too long. In terms of speed, the simpler approach (that fetches the whole set) is much better. |
I've mirrored the whole CLDR JSON v26 into a github repository. Then, I tried to publish it to an npm module. But, it failed:
Trying to fetch the full mirror via bower works. But, it's tedious. |
I've just created a CLDR JSON downloader https://github.com/rxaviers/cldr-data-downloader |
@raphamorim yeap. That script is my initial attempt to cherry-pick the files. This is, a custom downloader. But, that didn't work well. |
@rxaviers, I've only tested your guide in readme. The goal is when run this module, he auto identify and download the defined version in the package.json ? |
Both cldr-data and cldr-data-full npm modules have been created. They address the goal of this issue as follows.
On an i18n library, define which CLDR versions it's compatible with using its
The appropriate CLDR JSON data will be fetched with
Node.js users can access the data by using var cldr = require("cldr-data");
var plurals = cldr("supplemental/plurals"); It's ideal to use var Cldr = require("cldrjs");
var cldr = require("cldr-data");
Cldr.load(cldr("supplemental/plurals")); More info see README. |
Comparing installation times of the core coverage. Note the full coverage makes using github mirrors unusable.
Follow below the output I got running each command. Feel free to execute them yourself. npm mirror
bower mirror
npm + custom-downloader
bower + custom-downloader Requires setting up .bowerrc.
|
Goal
Winner approaches
npm + custom-downloader
Ideal for backend applications.
An npm module that uses a custom downloader. See npm's cldr-data npm module. The implementation of these modules have been inspired by phantomjs.
bower + post-install hook (or grunt task)
Ideal for frontend applications.
A bower module that contains CLDR data zip urls only (really light). It works as follows. A project foo depends on a variety of libraries that have different CLDR data requisites, which define that by using cldr-data bower module in their respective bower.json. When
bower install
is executed on project foo, it will resolve and flat the cldr-data versions of each dependencies and it will come up with a cldr-data that accommodates them all. A bower postinstall hook (e.g., cldr-data-downloader) or a grunt task (grunt-cldr-data-downloader) can be used in the sequence to download and populate the bower_components/cldr-data skeleton.See bower's cldr-data.
Unsuccessful approaches
npm mirror
❗ npm fails publishing the whole mirror. See comment below.
An npm module (e.g., cldr-data) contains all the CLDR JSON data. It follows the same version numbers of Unicode CLDR, for example cldr-data v26 has the same data served by http://www.unicode.org/Public/cldr/26/json-full.zip.
Usage, a library defines the cldr-data dependency in its
package.json
:Pros
Cons
npm + cherry-pick fetch
❗ fetching everything remotely takes way too long, see comment below.
An npm module (e.g., cldr-data) that follows the same version numbers of Unicode CLDR, but the module itself has no CLDR data. It has an
install.js
script that will be executed by npm during installation (thescripts/install
directive), which will fetch the needed files during installation. A kinda of variant of phantomjs, see https://gist.github.com/rxaviers/87e089c35d46fd3a1492.Usage, a library defines the cldr-data dependency in its
package.json
, plus it needs to define which CLDR data set to fetch.Pros
Cons
Question
bower mirror
❗ installing a whole mirror works. But, it takes awhile. Tedious. See comment below.
A cldr-data repository that contains all the CLDR JSON data. It follows the same version numbers of Unicode CLDR, for example cldr-data v26 has the same data served by http://www.unicode.org/Public/cldr/26/json-full.zip.
Usage, a library defines the cldr-data dependency in its
bower.json
:Pros
Cons
The text was updated successfully, but these errors were encountered: