The most translated copyright-free document on this planet: the universal declaration of human rights, in unicode, in JavaScript.
- What is this?
- When should I use this?
- Install
- Use
- API
- Data
- Types
- Compatibility
- Contribute
- Security
- License
This package exposes all UDHRs.
Perhaps when you are dealing with natural language detection?
This package is ESM only. In Node.js (version 14.14+, 16.0+), install with npm:
npm install udhr
In Deno with esm.sh
:
import {udhr} from 'https://esm.sh/udhr@5'
In browsers with esm.sh
:
<script type="module">
import {udhr} from 'https://esm.sh/udhr@5?bundle'
</script>
import fs from 'node:fs/promises'
import {resolve} from 'import-meta-resolve'
import {udhr} from 'udhr'
const bod = udhr.find((d) => d.code === 'bod')
console.log(bod)
const base = await resolve('udhr', import.meta.url)
// Declarations are stored as `declaration/$code.html`.
const url = new URL('declaration/' + bod.code + '.html', base)
console.log(String(await fs.readFile(url)))
Yields:
{
code: 'bod',
name: 'Tibetan, Central',
bcp47: 'bo',
ohchr: 'tic',
iso6393: 'bod',
direction: 'ltr',
stage: 4,
latitude: 28.37,
longitude: 90.19
}
<!doctype html>
<html lang="bo" dir="ltr" data-code="bod" data-iso6393="bod">
<head>
<title>Tibetan, Central</title>
</head>
<body>
<h1>༄༅༎ ཡོངས་ཁྱབ་གསལ་བསྒྲགས་འགྲོ་བ་མིའི་ཐོབ་ཐང༌།</h1>
<header>
<h2>སྔོན་བརྗོད།</h2>
<p>༈ འགྲོ་བ་མིའི་ཁྱིམ་ཚང་ཁག་གི་ནང་མི་ཡོངས་ལ་རང་བཞིན་ཉིད་ནས་ཡོད་པའི་ཆེ་མཐོངས་དང་འདྲ་མཉམ། སུས་ཀྱང་འཕྲོག་ཏུ་མི་རུང་བའི་ཐོབ་ཐང་བཅས་ཀྱི་གནད་དོན་རྟོགས པར་བྱེད་པ་ནི། འཛམ་གླིང་ནང་གི་རང་དབང་དང༌། དྲང་བདེན། ཞི་བདེ་བཅས་ཀྱི་རྣང་གཞི་ལྟེ་བ་ཡིན།</p>
…
This package exports the identifier udhr
.
There is no default export.
List of info objects. Gets info about the documents: their stage, language regions and lat/lng locations, &c.
console.log(udhr.find((d) => d.code === 'nob'))
Yields:
{
code: 'nob',
name: 'Norwegian, Bokmål',
bcp47: 'nb',
ohchr: 'nrr',
iso6393: 'nob',
direction: 'ltr',
stage: 4,
latitude: 61,
longitude: 8
}
The actual declarations are available in semantic HTML as
udhr/declaration/$code.html
.
This package is fully typed with TypeScript.
It exports the additional type Info
.
This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. It also works in Deno and modern browsers.
Yes please! See How to Contribute to Open Source.
This package is safe.