qudtlib-js-i18n
v0.3.0
Published
Multilingual labels extension for @qudtlib/allunits
Readme
qudtlib-js-i18n
Multilingual labels extension for @qudtlib/allunits.
@qudtlib/allunits ships only English (en / en-US) labels. This package patches Unit and QuantityKind instances at import time with ~14,000 labels from three sources:
- QUDT ontology — 20+ languages for units and quantity kinds
- Wikidata — French (
fr) only, filling gaps not covered by QUDT - AI/manual translation — French (
fr) only, for the ~700 quantity kinds not covered by either of the above
Note on French translations: French has 100% quantity kind coverage, but a significant portion of those labels were generated by AI (Claude) and reviewed by the project author — not sourced from an authoritative reference. They should be treated as unofficial and may not match the terminology used in French scientific literature or standards.
Installation
npm install qudtlib-js-i18nPeer dependencies (@qudtlib/allunits and @qudtlib/core) must also be installed:
npm install @qudtlib/allunits @qudtlib/coreUsage
Replace your existing import:
// Before
import { Units, Qudt } from "@qudtlib/allunits";
// After
import { Units, Qudt } from "qudtlib-js-i18n";Everything from @qudtlib/allunits is re-exported, and multilingual labels are applied as a side effect at import time.
Units
import { Units } from "qudtlib-js-i18n";
Units.M.getLabelForLanguageTag("de"); // "Meter"
Units.M.getLabelForLanguageTag("fr"); // "Mètre"
Units.M.getLabelForLanguageTag("ja"); // "メートル"
Units.M.getLabelForLanguageTag("zh"); // "米"
Units.M.getLabelForLanguageTag("en"); // "Metre" (still works)QuantityKinds
import { QuantityKinds, Qudt } from "qudtlib-js-i18n";
// Via the QuantityKinds object (autocomplete available)
QuantityKinds.Mass.getLabelForLanguageTag("de"); // "Masse"
QuantityKinds.Mass.getLabelForLanguageTag("fr"); // "masse"
QuantityKinds.Mass.getLabelForLanguageTag("ja"); // "質量"
// Via Qudt.quantityKindFromLocalname()
const vel = Qudt.quantityKindFromLocalname("Velocity");
vel?.getLabelForLanguageTag("fr"); // "vitesse"
// Via full IRI
const temp = Qudt.quantityKind("http://qudt.org/vocab/quantitykind/Temperature");
temp?.getLabelForLanguageTag("fr"); // "température"Languages covered
| Source | Languages |
|---|---|
| QUDT ontology | Arabic (ar), Bulgarian (bg), Czech (cs), German (de), Greek (el), Spanish (es), Persian (fa), French (fr), Hebrew (he), Hindi (hi), Hungarian (hu), Italian (it), Japanese (ja), Latin (la), Malay (ms), Polish (pl), Portuguese (pt), Romanian (ro), Russian (ru), Slovenian (sl), Turkish (tr), Chinese (zh), and more |
| Wikidata | French (fr) — units and quantity kinds only |
| AI translation (unofficial) | French (fr) — quantity kinds only, where QUDT and Wikidata have no French label |
French has the broadest coverage, but note that a large portion of its quantity kind labels are AI-generated and unofficial (see note above).
Keeping labels up to date
Labels are regenerated weekly from the QUDT ontology and Wikidata via a GitHub Actions workflow. You can also regenerate manually:
npm run generateESM only
This package is ESM-only ("type": "module").
