@siakhooi/number-to-chinese-words
TypeScript icon, indicating that this package has built-in type declarations

1.12.4 • Public • Published

number-to-chinese-words

  • npm package to translate number to chinese words

License Code Style GitHub last commit GitHub tag (latest by date) GitHub issues GitHub closed issues GitHub pull requests GitHub closed pull requests GitHub top language

Release npm npm npm type definitions

Quality-CodeClimate Maintainability Code Climate maintainability Code Climate issues Code Climate technical debt Test Coverage

Quality-Sonar Code Smells Duplicated Lines (%) Bugs Vulnerabilities Technical Debt Maintainability Rating Security Rating Reliability Rating Quality Gate Status

Generic badge Generic badge count

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.(分厘毫秒忽微纤沙尘埃渺漠)

Locations

Demo

Source Code

Distributions

Quality

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

GitHub language count Lines of code GitHub repo size GitHub code size in bytes Workflow workflow workflow Release GitHub release (latest by date) GitHub all releases GitHub Release Date Quality-npms.io npms.io (final) npms.io (final) npms.io (final) npms.io (final) Quality-Sonar Lines of Code Coverage Sonar Violations (short format) Sonar Violations (short format) Sonar Violations (short format) Sonar Violations (short format) Sonar Violations (short format) Sonar Violations (short format) Sonar Violations (long format) Quality-Coveralls Coverage Status Quality-Codecov Codecov Quality-Codacy Codacy Badge Codacy Badge Quality-CodeFactor CodeFactor Quality-Snyk Snyk Vulnerabilities for GitHub Repo Snyk Vulnerabilities for npm package Quality-LGTM LGTM Alerts LGTM Grade Quality-Coverity Coverity Scan

Readme

Keywords

Package Sidebar

Install

npm i @siakhooi/number-to-chinese-words

Weekly Downloads

28

Version

1.12.4

License

MIT

Unpacked Size

48.9 kB

Total Files

21

Last publish

Collaborators

  • siakhooi