Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including cldr-tools with all npm packages installed. Try it out:

cldr-tools lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("cldr-tools/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

cldr-tools v0.1.0

utility tools for cldr

CLDR Tools

Build Status Coverage Status

NPM

Please Note

This is an experimental project, modules or api may change frequently.

This project aim to build utility and convenient tools for CLDR(Common Locale Data Repository, which have a lot of all kinds of data in all over 200+ languages).

Hope to help front-end developers to build globalization applications.

Features (for now)

Features (to be implemented)

  • decimal formatting: some thing like 1000000000 => 1 billion(in English) but 10亿(in Chinese)
  • other many fun functions

Getting Started

$ npm install cldr-tools

search locales by language name

const search = require('cldr-tools/lib/search/available-locales')

search('English') // => ['en', 'en-AU', 'en-CA', 'en-GB']
search('英文') // => ['en', 'en-AU', 'en-CA', 'en-GB']
search('中文') // => ['zh', 'zh-Hans', 'zh-Hant']
search('Chinese') // => ['zh', 'zh-Hans', 'zh-Hant']
search('日文') // => ['ja']
search('日本語') // => ['ja']

get languages' display name

const languageDisplayNames = require('cldr-tools/lib/display-names/languages')

languageDisplayNames(['zh', 'en'])
// => [{
   locale: 'zh',
   displayName: '中文'
}, {
   locale: 'en',
   displayName: 'English'
}]

languageDisplayNames(['zh', 'en'], 'en')
// => [{
   locale: 'zh',
   displayName: 'Chinese'
}, {
   locale: 'en',
   displayName: 'English'
}]


languageDisplayNames(['zh', 'en'], 'en', true)
// => [{
   locale: 'zh',
   displayName: 'Chinese',
   original: '中文'
}, {
   locale: 'en',
   displayName: 'English',
   original: 'English'
}]

Command line tool

could search locales in your terminal

see cldr-cli

Documentation

waiting to be write

Contribute

This project is a fresh start, welcome to contribute! Please follow the Github Flow

Requirements

  • This is open source project, so unit test is required. Using Mocha, chai, sinon so far.
  • Comments are welcome and expected
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free