https://github.com/redsift/d3-rs-intl
https://github.com/redsift/d3-rs-intl
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/redsift/d3-rs-intl
- Owner: redsift
- License: mit
- Created: 2016-06-20T23:53:40.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-03-16T14:57:16.000Z (about 2 years ago)
- Last Synced: 2025-09-27T22:52:50.052Z (9 months ago)
- Language: HTML
- Size: 1.28 MB
- Stars: 0
- Watchers: 17
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# d3-rs-intl
`d3-rs-intl` is a module that includes a few Internationalization tools for D3v4.
## Builds
[](https://circleci.com/gh/Redsift/d3-rs-intl)
## Example
[View @redsift/d3-rs-intl on Codepen](https://....)
## Usage
### Browser
var l = d3_rs_intl.time();
var t = d3.timeFormatLocale(l.d3).format('%c')(new Date());
### ES6
import { units } from "@redsift/d3-rs-intl";
let l = units([ 'en-GB', 'en' ]);
...
### Require
var intl = require("@redsift/d3-rs-intl");
var l = intl.units(intl.lookup('Catalan'));
...
The main helpers in this module are `time()` and `units()` which can optionally take an array of preferred ISO 639 `language-CULTURE` or `language` values and return the appropriate formatter. This formatter can be used by [d3-format](https://github.com/d3/d3-format#locale_format) and [d3-time-format](https://github.com/d3/d3-time-format#locale_format) to emit localized values such as decimal separators, currency and day names.
If no parameters are supplied, both methods attempt to use the browser preferences.
## Building
As this package builds the node using imported JSON locales from d3-format and d3-time-format, you will need a JSON -> JS convesion helper in your build process if you are using a tool like Rollup, e.g. `rollup-plugin-json`.