n2words 1.9.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +64 -5
- package/CHANGELOG.md +34 -0
- package/README.md +33 -14
- package/dist/n2words.js +1 -1
- package/lib/classes/N2WordsAbs.mjs +55 -34
- package/lib/classes/N2WordsBase.mjs +25 -19
- package/lib/i18n/AR.mjs +91 -83
- package/lib/i18n/CZ.mjs +80 -74
- package/lib/i18n/DE.mjs +82 -73
- package/lib/i18n/DK.mjs +82 -73
- package/lib/i18n/EN.mjs +68 -54
- package/lib/i18n/ES.mjs +86 -77
- package/lib/i18n/FA.mjs +67 -62
- package/lib/i18n/FR.mjs +72 -63
- package/lib/i18n/HE.mjs +40 -33
- package/lib/i18n/HR.mjs +117 -0
- package/lib/i18n/HU.mjs +70 -64
- package/lib/i18n/ID.mjs +155 -0
- package/lib/i18n/IT.mjs +46 -40
- package/lib/i18n/KO.mjs +44 -35
- package/lib/i18n/LT.mjs +86 -80
- package/lib/i18n/LV.mjs +74 -67
- package/lib/i18n/NL.mjs +92 -87
- package/lib/i18n/NO.mjs +65 -56
- package/lib/i18n/PL.mjs +81 -75
- package/lib/i18n/PT.mjs +85 -77
- package/lib/i18n/RU.mjs +99 -93
- package/lib/i18n/SR.mjs +83 -77
- package/lib/i18n/TR.mjs +227 -218
- package/lib/i18n/UK.mjs +80 -74
- package/lib/i18n/ZH.mjs +52 -41
- package/lib/n2words.mjs +60 -54
- package/package.json +17 -20
- package/webpack.config.js +2 -5
- package/lib/n2words_EN.mjs +0 -11
package/lib/i18n/FA.mjs
CHANGED
|
@@ -1,54 +1,56 @@
|
|
|
1
1
|
import N2WordsAbs from '../classes/N2WordsAbs.mjs';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export class N2WordsFA extends N2WordsAbs {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
7
|
+
this.negativeWord = 'منفى';
|
|
8
|
+
this.separatorWord = 'ممیّز';
|
|
9
|
+
this.zero = 'صفر';
|
|
10
|
+
this.namedNumbers = {
|
|
11
|
+
0: 'صفر',
|
|
12
|
+
1: 'یک',
|
|
13
|
+
2: 'دو',
|
|
14
|
+
3: 'سه',
|
|
15
|
+
4: 'چهار',
|
|
16
|
+
5: 'پنج',
|
|
17
|
+
6: 'شش',
|
|
18
|
+
7: 'هفت',
|
|
19
|
+
8: 'هشت',
|
|
20
|
+
9: 'نه',
|
|
21
|
+
10: 'ده',
|
|
22
|
+
11: 'یازده',
|
|
23
|
+
12: 'دوازده',
|
|
24
|
+
13: 'سیزده',
|
|
25
|
+
14: 'چهارده',
|
|
26
|
+
15: 'پانزده',
|
|
27
|
+
16: 'شانزده',
|
|
28
|
+
17: 'هفده',
|
|
29
|
+
18: 'هجده',
|
|
30
|
+
19: 'نوزده',
|
|
31
|
+
20: 'بیست',
|
|
32
|
+
30: 'سی',
|
|
33
|
+
40: 'چهل',
|
|
34
|
+
50: 'پنجاه',
|
|
35
|
+
60: 'شصت',
|
|
36
|
+
70: 'هفتاد',
|
|
37
|
+
80: 'هشتاد',
|
|
38
|
+
90: 'نود',
|
|
39
|
+
100: 'صد',
|
|
40
|
+
200: 'دویست',
|
|
41
|
+
300: 'سيصد',
|
|
42
|
+
400: 'چهار صد',
|
|
43
|
+
500: 'پانصد',
|
|
44
|
+
600: 'ششصد',
|
|
45
|
+
700: 'هفتصد',
|
|
46
|
+
800: 'هشتصد',
|
|
47
|
+
900: 'نهصد',
|
|
48
|
+
1000: 'هزار',
|
|
49
|
+
1000000: 'میلیون',
|
|
50
|
+
};
|
|
51
|
+
}
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
toCardinal(number) {
|
|
52
54
|
if (this.namedNumbers[number]) {
|
|
53
55
|
return this.namedNumbers[number];
|
|
54
56
|
}
|
|
@@ -63,25 +65,28 @@ export default function () {
|
|
|
63
65
|
return `${this.namedNumbers[xhundred]} و ${tail}`;
|
|
64
66
|
}
|
|
65
67
|
if (number > 1000 && number < 1000000) {
|
|
66
|
-
let
|
|
67
|
-
let
|
|
68
|
-
(
|
|
68
|
+
let thousandMultiplier = parseInt(number / 1000);
|
|
69
|
+
let namedThousandMultiplier =
|
|
70
|
+
(thousandMultiplier === 1
|
|
69
71
|
? ''
|
|
70
|
-
: this.toCardinal(
|
|
72
|
+
: this.toCardinal(thousandMultiplier)) +
|
|
71
73
|
' ' +
|
|
72
74
|
this.namedNumbers[1000];
|
|
73
|
-
let
|
|
74
|
-
let tail =
|
|
75
|
-
return `${
|
|
75
|
+
let tailNumber = number - thousandMultiplier * 1000;
|
|
76
|
+
let tail = tailNumber === 0 ? '' : ' ' + this.toCardinal(tailNumber);
|
|
77
|
+
return `${namedThousandMultiplier}${tail}`;
|
|
76
78
|
}
|
|
77
79
|
if (number > 1000000) {
|
|
78
|
-
let
|
|
79
|
-
let
|
|
80
|
-
this.toCardinal(
|
|
81
|
-
let
|
|
82
|
-
let tail =
|
|
83
|
-
return `${
|
|
80
|
+
let millionMultiplier = parseInt(number / 1000000);
|
|
81
|
+
let namedMillion =
|
|
82
|
+
this.toCardinal(millionMultiplier) + ' ' + this.namedNumbers[1000000];
|
|
83
|
+
let tailNumber = number - millionMultiplier * 1000000;
|
|
84
|
+
let tail = tailNumber === 0 ? '' : ' و ' + this.toCardinal(tailNumber);
|
|
85
|
+
return `${namedMillion}${tail}`;
|
|
84
86
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default function(n) {
|
|
91
|
+
return new N2WordsFA().floatToCardinal(n);
|
|
87
92
|
}
|
package/lib/i18n/FR.mjs
CHANGED
|
@@ -1,77 +1,86 @@
|
|
|
1
1
|
import N2WordsBase from '../classes/N2WordsBase.mjs';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export class N2WordsFR extends N2WordsBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
7
|
+
this.negativeWord = 'moins';
|
|
8
|
+
this.separatorWord = 'virgule';
|
|
9
|
+
this.zero = 'zéro';
|
|
10
|
+
this.cards = [
|
|
11
|
+
{ '1000000000000000000000000000': 'quadrilliard' },
|
|
12
|
+
{ '1000000000000000000000000': 'quadrillion' },
|
|
13
|
+
{ '1000000000000000000000': 'trilliard' },
|
|
14
|
+
{ '1000000000000000000': 'trillion' },
|
|
15
|
+
{ '1000000000000000': 'billiard' },
|
|
16
|
+
{ '1000000000000': 'billion' },
|
|
17
|
+
{ '1000000000': 'milliard' },
|
|
18
|
+
{ '1000000': 'million' },
|
|
19
|
+
{ '1000': 'mille' },
|
|
20
|
+
{ '100': 'cent' },
|
|
21
|
+
{ '80': 'quatre-vingts' },
|
|
22
|
+
{ '60': 'soixante' },
|
|
23
|
+
{ '50': 'cinquante' },
|
|
24
|
+
{ '40': 'quarante' },
|
|
25
|
+
{ '30': 'trente' },
|
|
26
|
+
{ '20': 'vingt' },
|
|
27
|
+
{ '19': 'dix-neuf' },
|
|
28
|
+
{ '18': 'dix-huit' },
|
|
29
|
+
{ '17': 'dix-sept' },
|
|
30
|
+
{ '16': 'seize' },
|
|
31
|
+
{ '15': 'quinze' },
|
|
32
|
+
{ '14': 'quatorze' },
|
|
33
|
+
{ '13': 'treize' },
|
|
34
|
+
{ '12': 'douze' },
|
|
35
|
+
{ '11': 'onze' },
|
|
36
|
+
{ '10': 'dix' },
|
|
37
|
+
{ '9': 'neuf' },
|
|
38
|
+
{ '8': 'huit' },
|
|
39
|
+
{ '7': 'sept' },
|
|
40
|
+
{ '6': 'six' },
|
|
41
|
+
{ '5': 'cinq' },
|
|
42
|
+
{ '4': 'quatre' },
|
|
43
|
+
{ '3': 'trois' },
|
|
44
|
+
{ '2': 'deux' },
|
|
45
|
+
{ '1': 'un' },
|
|
46
|
+
{ '0': 'zéro' }
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
merge(curr, next) { // {'cent':100}, {'vingt-cinq':25}
|
|
51
|
+
let cText = Object.keys(curr)[0];
|
|
52
|
+
let nText = Object.keys(next)[0];
|
|
53
|
+
const cNum = parseInt(Object.values(curr)[0]);
|
|
54
|
+
const nNum = parseInt(Object.values(next)[0]);
|
|
55
|
+
if (cNum == 1) {
|
|
56
|
+
if (nNum < 1000000) {
|
|
57
|
+
return { [nText]: nNum };
|
|
53
58
|
}
|
|
54
59
|
} else {
|
|
55
60
|
if (
|
|
56
|
-
((
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
((cNum - 80) % 100 == 0 || (cNum % 100 == 0 && cNum < 1000)) &&
|
|
62
|
+
nNum < 1000000 &&
|
|
63
|
+
cText[cText.length - 1] == 's'
|
|
59
64
|
) {
|
|
60
|
-
|
|
65
|
+
cText = cText.slice(0, -1); // without last elem
|
|
61
66
|
}
|
|
62
67
|
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
cNum < 1000 && nNum != 1000 &&
|
|
69
|
+
nText[nText.length - 1] != 's' &&
|
|
70
|
+
nNum % 100 == 0
|
|
66
71
|
) {
|
|
67
|
-
|
|
72
|
+
nText += 's';
|
|
68
73
|
}
|
|
69
74
|
}
|
|
70
|
-
if (
|
|
71
|
-
if (
|
|
72
|
-
return { [`${
|
|
75
|
+
if (nNum < cNum && cNum < 100) {
|
|
76
|
+
if (nNum % 10 == 1 && cNum != 80) return { [`${cText} et ${nText}`]: cNum + nNum };
|
|
77
|
+
return { [`${cText}-${nText}`]: cNum + nNum };
|
|
73
78
|
}
|
|
74
|
-
if (
|
|
75
|
-
return { [`${
|
|
76
|
-
}
|
|
79
|
+
if (nNum > cNum) return { [`${cText} ${nText}`]: cNum * nNum };
|
|
80
|
+
return { [`${cText} ${nText}`]: cNum + nNum };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default function(n) {
|
|
85
|
+
return new N2WordsFR().floatToCardinal(n);
|
|
77
86
|
}
|
package/lib/i18n/HE.mjs
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {N2WordsRU} from './RU.mjs';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export class N2WordsHE extends N2WordsRU {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
this.negativeWord = 'מינוס'; //TODO: Needs confirmation
|
|
8
|
+
this.separatorWord; //TODO
|
|
9
|
+
this.zero = 'אפס';
|
|
10
|
+
this.and = 'ו';
|
|
11
|
+
this.ones = { 1: 'אחת', 2: 'שתים', 3: 'שלש', 4: 'ארבע', 5: 'חמש', 6: 'שש', 7: 'שבע', 8: 'שמונה', 9: 'תשע' };
|
|
12
|
+
this.tens = {
|
|
13
|
+
0: 'עשר', 1: 'אחת עשרה', 2: 'שתים עשרה', 3: 'שלש עשרה', 4: 'ארבע עשרה',
|
|
14
|
+
5: 'חמש עשרה', 6: 'שש עשרה', 7: 'שבע עשרה', 8: 'שמונה עשרה', 9: 'תשע עשרה'
|
|
15
|
+
};
|
|
16
|
+
this.twenties = {
|
|
17
|
+
2: 'עשרים', 3: 'שלשים', 4: 'ארבעים', 5: 'חמישים', 6: 'ששים', 7: 'שבעים', 8: 'שמונים', 9: 'תשעים'
|
|
18
|
+
};
|
|
19
|
+
this.hundreds = { 1: 'מאה', 2: 'מאתיים', 3: 'מאות' };
|
|
20
|
+
this.thousands = {
|
|
21
|
+
1: 'אלף', 2: 'אלפיים', 3: 'שלשת אלפים', 4: 'ארבעת אלפים',
|
|
22
|
+
5: 'חמשת אלפים', 6: 'ששת אלפים', 7: 'שבעת אלפים', 8: 'שמונת אלפים', 9: 'תשעת אלפים'
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
toCardinal(number) {
|
|
24
27
|
if (parseInt(number) == 0) {
|
|
25
|
-
return this.
|
|
28
|
+
return this.zero;
|
|
26
29
|
}
|
|
27
30
|
const words = [];
|
|
28
|
-
const chunks = this.
|
|
31
|
+
const chunks = this.splitByX(JSON.stringify(number), 3);
|
|
29
32
|
let i = chunks.length;
|
|
30
33
|
for (let j = 0; j < chunks.length; j++) {
|
|
31
34
|
const x = chunks[j];
|
|
@@ -33,33 +36,37 @@ export default function () {
|
|
|
33
36
|
if (x == 0) {
|
|
34
37
|
continue;
|
|
35
38
|
}
|
|
36
|
-
const [n1, n2, n3] = this.
|
|
39
|
+
const [n1, n2, n3] = this.getDigits(x);
|
|
37
40
|
if (i > 0) {
|
|
38
|
-
words.push(this.
|
|
41
|
+
words.push(this.thousands[n1]);
|
|
39
42
|
continue;
|
|
40
43
|
}
|
|
41
44
|
if (n3 > 0) {
|
|
42
45
|
if (n3 <= 2) {
|
|
43
|
-
words.push(this.
|
|
46
|
+
words.push(this.hundreds[n3]);
|
|
44
47
|
} else {
|
|
45
|
-
words.push(this.
|
|
48
|
+
words.push(this.ones[n3] + ' ' + this.hundreds[3]);
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
if (n2 > 1) {
|
|
49
|
-
words.push(this.
|
|
52
|
+
words.push(this.twenties[n2]);
|
|
50
53
|
}
|
|
51
54
|
if (n2 == 1) {
|
|
52
|
-
words.push(this.
|
|
55
|
+
words.push(this.tens[n1]);
|
|
53
56
|
} else if (n1 > 0 && !(i > 0 && x == 1)) {
|
|
54
|
-
words.push(this.
|
|
57
|
+
words.push(this.ones[n1]);
|
|
55
58
|
}
|
|
56
59
|
if (i > 0) {
|
|
57
|
-
words.push(this.
|
|
60
|
+
words.push(this.thousands[i]);
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
if (words.length > 1) {
|
|
61
|
-
words[words.length - 1] = this.
|
|
64
|
+
words[words.length - 1] = this.and + words[words.length - 1];
|
|
62
65
|
}
|
|
63
66
|
return words.join(' ');
|
|
64
|
-
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default function(n) {
|
|
71
|
+
return new N2WordsHE().floatToCardinal(n);
|
|
65
72
|
}
|
package/lib/i18n/HR.mjs
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {N2WordsRU} from './RU.mjs';
|
|
2
|
+
|
|
3
|
+
export class N2WordsHR extends N2WordsRU {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
|
|
7
|
+
this.negativeWord = 'minus';
|
|
8
|
+
this.separatorWord = 'zarez';
|
|
9
|
+
this.zero = 'nula';
|
|
10
|
+
this.ones = {
|
|
11
|
+
1: ['jedan', 'jedna'],
|
|
12
|
+
2: ['dva', 'dvije'],
|
|
13
|
+
3: ['tri', 'tri'],
|
|
14
|
+
4: ['četiri', 'četiri'],
|
|
15
|
+
5: ['pet', 'pet'],
|
|
16
|
+
6: ['šest', 'šest'],
|
|
17
|
+
7: ['sedam', 'sedam'],
|
|
18
|
+
8: ['osam', 'osam'],
|
|
19
|
+
9: ['devet', 'devet']
|
|
20
|
+
};
|
|
21
|
+
this.tens = {
|
|
22
|
+
0: 'deset',
|
|
23
|
+
1: 'jedanaest',
|
|
24
|
+
2: 'dvanaest',
|
|
25
|
+
3: 'trinaest',
|
|
26
|
+
4: 'četrnaest',
|
|
27
|
+
5: 'petnaest',
|
|
28
|
+
6: 'šesnaest',
|
|
29
|
+
7: 'sedamnaest',
|
|
30
|
+
8: 'osamnaest',
|
|
31
|
+
9: 'devetnaest'
|
|
32
|
+
};
|
|
33
|
+
this.twenties = {
|
|
34
|
+
2: 'dvadeset',
|
|
35
|
+
3: 'trideset',
|
|
36
|
+
4: 'četrdeset',
|
|
37
|
+
5: 'pedeset',
|
|
38
|
+
6: 'šezdeset',
|
|
39
|
+
7: 'sedamdeset',
|
|
40
|
+
8: 'osamdeset',
|
|
41
|
+
9: 'devedeset'
|
|
42
|
+
};
|
|
43
|
+
this.hundreds = {
|
|
44
|
+
1: 'sto',
|
|
45
|
+
2: 'dvjesto',
|
|
46
|
+
3: 'tristo',
|
|
47
|
+
4: 'četiristo',
|
|
48
|
+
5: 'petsto',
|
|
49
|
+
6: 'šesto',
|
|
50
|
+
7: 'sedamsto',
|
|
51
|
+
8: 'osamsto',
|
|
52
|
+
9: 'devetsto'
|
|
53
|
+
};
|
|
54
|
+
this.SCALE = {
|
|
55
|
+
0: ['', '', '', false],
|
|
56
|
+
1: ['tisuća', 'tisuće', 'tisuća', true], // 10 ^ 3
|
|
57
|
+
2: ['milijun', 'milijuna', 'milijuna', false], // 10 ^ 6
|
|
58
|
+
3: ['milijarda', 'milijarde', 'milijarda', false], // 10 ^ 9
|
|
59
|
+
4: ['bilijun', 'bilijuna', 'bilijuna', false], // 10 ^ 12
|
|
60
|
+
5: ['bilijarda', 'bilijarde', 'bilijarda', false], // 10 ^ 15
|
|
61
|
+
6: ['trilijun', 'trilijuna', 'trilijuna', false], // 10 ^ 18
|
|
62
|
+
7: ['trilijarda', 'trilijarde', 'trilijarda', false], // 10 ^ 21
|
|
63
|
+
8: ['kvadrilijun', 'kvadrilijuna', 'kvadrilijuna', false], // 10 ^ 24
|
|
64
|
+
9: ['kvadrilijarda', 'kvadrilijarde', 'kvadrilijarda', false], // 10 ^ 27
|
|
65
|
+
10: ['kvintilijun', 'kvintilijuna', 'kvintilijuna', false], // 10 ^ 30
|
|
66
|
+
};
|
|
67
|
+
this.feminine = false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
pluralize(n, forms) {
|
|
71
|
+
let form = 2;
|
|
72
|
+
if ((n % 100 < 10) || (n % 100 > 20)) {
|
|
73
|
+
if (n % 10 == 1) {
|
|
74
|
+
form = 0;
|
|
75
|
+
} else if ((n % 10 > 1) && (n % 10 < 5)) {
|
|
76
|
+
form = 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return forms[form];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
toCardinal(number) {
|
|
83
|
+
if (parseInt(number) == 0) {
|
|
84
|
+
return this.zero;
|
|
85
|
+
}
|
|
86
|
+
const words = [];
|
|
87
|
+
const chunks = this.splitByX(JSON.stringify(number), 3);
|
|
88
|
+
let i = chunks.length;
|
|
89
|
+
for (let j = 0; j < chunks.length; j++) {
|
|
90
|
+
const x = chunks[j];
|
|
91
|
+
i = i - 1;
|
|
92
|
+
// if (x == 0) { continue; }
|
|
93
|
+
const [n1, n2, n3] = this.getDigits(x);
|
|
94
|
+
if (n3 > 0) {
|
|
95
|
+
words.push(this.hundreds[n3]);
|
|
96
|
+
}
|
|
97
|
+
if (n2 > 1) {
|
|
98
|
+
words.push(this.twenties[n2]);
|
|
99
|
+
}
|
|
100
|
+
if (n2 == 1) {
|
|
101
|
+
words.push(this.tens[n1]);
|
|
102
|
+
} else if (n1 > 0) {
|
|
103
|
+
const isFeminine = (this.feminine || this.SCALE[i][3]);
|
|
104
|
+
const genderIdx = isFeminine ? 1 : 0;
|
|
105
|
+
words.push(this.ones[n1][genderIdx]);
|
|
106
|
+
}
|
|
107
|
+
if ((i > 0) && (x != 0)) {
|
|
108
|
+
words.push(this.pluralize(x, this.SCALE[i]));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return words.join(' ');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export default function(n) {
|
|
116
|
+
return new N2WordsHR().floatToCardinal(n);
|
|
117
|
+
}
|