1.12.4 • Published 3 years ago
@siakhooi/number-to-chinese-words v1.12.4
number-to-chinese-words
- npm package to translate number to chinese words
Features
- Translate numbers into Chinese characters for:
- Integer -9007,1992,5474,0991 to +9007,1992,5474,0991 (
Number.MAX_SAFE_INTEGER) - support decimal points
- Simplified Chinese or Traditional Chinese (
options: {useTraditional: true}) - optionally display
正for positive numbers. (options:{displayPositive: true}) - optionally use capital (大写). (
options: {useCapital: true}) - optionally remove leading one. (
options: {removeLeadingOne: true}) - optionally use contractions (
廿卅卌圩圆进枯桦皕) - optionally use traditional units for floating numbers.(
分厘毫秒忽微纤沙尘埃渺漠)
- Integer -9007,1992,5474,0991 to +9007,1992,5474,0991 (
Locations
Demo
Source Code
Distributions
- https://www.npmjs.com/package/@siakhooi/number-to-chinese-words
- https://github.com/siakhooi/ts-number-to-chinese-words/pkgs/npm/number-to-chinese-words
Quality
- https://sonarcloud.io/project/overview?id=siakhooi_ts-number-to-chinese-words
- https://codeclimate.com/github/siakhooi/ts-number-to-chinese-words
- https://coveralls.io/github/siakhooi/ts-number-to-chinese-words
- https://app.codecov.io/gh/siakhooi/ts-number-to-chinese-words
- https://app.codacy.com/gh/siakhooi/ts-number-to-chinese-words
- https://www.codefactor.io/repository/github/siakhooi/ts-number-to-chinese-words
- https://app.snyk.io/org/siakhooi/projects
- https://lgtm.com/people/siakhooi/project:1515605457625
- https://scan.coverity.com/projects/siakhooi-ts-number-to-chinese-words?tab=overview
Options and Default values
options: {
useTraditional: false;
displayPositive: false;
useCapital: false;
removeLeadingOne: false;
useContractionAll: false;
useContraction20: false;
useContraction30: false;
useContraction40: false;
useContraction50: false;
useContraction60: false;
useContraction70: false;
useContraction80: false;
useContraction90: false;
useContraction200: false;
useTraditionalFloatingUnit: false;
}Usage
const NumberToChinese = require('@siakhooi/number-to-chinese-words');
console.log(NumberToChinese.convertNumber(7));
const NumberToChinese = require('@siakhooi/number-to-chinese-words');
console.log(NumberToChinese.convertNumber(7, {useTraditional: true}));
const NumberToChinese = require('@siakhooi/number-to-chinese-words');
console.log(NumberToChinese.convertNumber(7, {displayPositive: true}));
const NumberToChinese = require('@siakhooi/number-to-chinese-words');
console.log(NumberToChinese.convertNumber(7, {useCapital: true}));
const NumberToChinese = require('@siakhooi/number-to-chinese-words');
console.log(NumberToChinese.convertNumber(17, {removeLeadingOne: true}));
const NumberToChinese = require('@siakhooi/number-to-chinese-words');
console.log(NumberToChinese.convertNumber(70, {useContraction70: true}));Example
Simplified and Traditional
| number | Simplified | Traditional |
|---|---|---|
| 0 | 零 | 零 |
| 17 | 一十七 | 一十七 |
| 999 | 九百九十九 | 九百九十九 |
| 9999 | 九千九百九十九 | 九千九百九十九 |
| 10101 | 一万零一百零一 | 一萬零一百零一 |
| 100001 | 一十万零一 | 一十萬零一 |
| 3004500 | 三百万四千五百 | 三百萬四千五百 |
| 10000001 | 一千万零一 | 一千萬零一 |
| 43033039 | 四千三百零三万三千零三十九 | 四千三百零三萬三千零三十九 |
| 12345678 | 一千二百三十四万五千六百七十八 | 一千二百三十四萬五千六百七十八 |
| 100000000 | 一亿 | 一億 |
| 1010101010 | 一十亿一千零一十万一千零一十 | 一十億一千零一十萬一千零一十 |
| 10101010101 | 一百零一亿零一百零一万零一百零一 | 一百零一億零一百零一萬零一百零一 |
| 999999999999 | 九千九百九十九亿九千九百九十九万九千九百九十九 | 九千九百九十九億九千九百九十九萬九千九百九十九 |
| 9007199254740991 | 九千零七兆一千九百九十二亿五千四百七十四万零九百九十一 | 九千零七兆一千九百九十二億五千四百七十四萬零九百九十一 |
display positive
| number | displayPositive=true | displayPositive=false |
|---|---|---|
| -17 | 负一十七 | 负一十七 |
| 17 | 正一十七 | 一十七 |
capital
| number | useCapital=true | useCapital=true,useTraditional=true |
|---|---|---|
| -107 | 负壹佰零柒 | 負壹佰零柒 |
| 2345 | 贰仟叁佰肆拾伍 | 貳仟參佰肆拾伍 |
remove Leading One
| number | Simplified | Traditional |
|---|---|---|
| 17 | 十七 | 十七 |
| 10101 | 万零一百零一 | 萬零一百零一 |
| 100001 | 十万零一 | 十萬零一 |
| 10000001 | 千万零一 | 千萬零一 |
| 12345678 | 千二百三十四万五千六百七十八 | 千二百三十四萬五千六百七十八 |
| 100000000 | 亿 | 億 |
| 1010101010 | 十亿一千零一十万一千零一十 | 十億一千零一十萬一千零一十 |
| 10101010101 | 百零一亿零一百零一万零一百零一 | 百零一億零一百零一萬零一百零一 |
Decimal Points
| number | Simplified | Traditional |
|---|---|---|
| 12.13 | 一十二点一三 | 一十二點一三 |
| 10.123456789012 | 一十点一二三四五六七八九零一二 | 一十點一二三四五六七八九零一二 |
Contraction
| number | Simplified | Traditional |
|---|---|---|
| 20 | 廿 | 廿 |
| 30 | 卅 | 卅 |
| 40 | 卌 | 卌 |
| 50 | 圩 | 圩 |
| 60 | 圆 | 圓 |
| 70 | 进 | 進 |
| 80 | 枯 | 枯 |
| 90 | 桦 | 樺 |
| 200 | 皕 | 皕 |
Traditional Floating Unit
| number | Simplified | Traditional |
|---|---|---|
| 12.13 | 一十二又一分三厘 | 一十二又一分三釐 |
| 0.123456789123 | 一分二厘三毫四秒五忽六微七纤八沙九尘一埃二渺三漠 | 一分二釐三毫四秒五忽六微七纖八沙九塵一埃二渺三漠 |
Other Badges
1.12.4
3 years ago
1.12.1
3 years ago
1.12.0
3 years ago
1.9.0
4 years ago
1.8.0
4 years ago
1.7.0
4 years ago
1.6.1
4 years ago
1.6.0
4 years ago
1.5.0
4 years ago
1.4.0
4 years ago
1.11.0
4 years ago
1.10.0
4 years ago
1.3.0
4 years ago
1.2.0
4 years ago
1.1.0
4 years ago
1.0.0
4 years ago
0.0.6
4 years ago
0.0.5
4 years ago
0.0.4
4 years ago
0.0.3
4 years ago
0.0.2
4 years ago
0.0.1
4 years ago
0.0.0
4 years ago