chinese-numbering
format numbers as chinese words and ordinals
Install
npm install chinese-numberingyarn add chinese-numbering
Usage
import
-
Node.js
const cn = ;console; -
Browser
-
with iife / umd bundle:
-
with es module bundle:
-
-
ES Modules
;console;
number to Simplified / Traditional Chinese
// Simplified Chinese 简体中文// 一万零一点六cn;cn;cn;cn; // Tradition Chinese 繁體中文// 一萬零一點六cn;cn;cn; // negative numbers 负数cn; // 负一千二百cn; // 負零點五
One
Keep the first // not keep the first `One`cn; // 十二// Keep the first `One`cn; // 一十二
Ordinal
cn; // 第十二cn; // 第一十二cn; // 第一萬 // with Arabic numeralscn; // 第12
License
MIT © Equal Ma
The algorithm to format number as Chinese words is inspired by digi3studio/number-to-chinese-words. Great Thanks to digi3studio.