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/HU.mjs
CHANGED
|
@@ -1,62 +1,64 @@
|
|
|
1
1
|
import N2WordsBase from '../classes/N2WordsBase.mjs';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export class N2WordsHU 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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
7
|
+
this.negativeWord = 'mínusz';
|
|
8
|
+
this.separatorWord = 'egész';
|
|
9
|
+
this.cards = [
|
|
10
|
+
{ '1000000000000000000000000000': 'quadrilliárd' },
|
|
11
|
+
{ '1000000000000000000000000': 'quadrillió' },
|
|
12
|
+
{ '1000000000000000000000': 'trilliárd' },
|
|
13
|
+
{ '1000000000000000000': 'trillió' },
|
|
14
|
+
{ '1000000000000000': 'billiárd' },
|
|
15
|
+
{ '1000000000000': 'billió' },
|
|
16
|
+
{ '1000000000': 'milliárd' },
|
|
17
|
+
{ '1000000': 'millió' },
|
|
18
|
+
{ '1000': 'ezer' },
|
|
19
|
+
{ '100': 'száz' },
|
|
20
|
+
{ '90': 'kilencven' },
|
|
21
|
+
{ '80': 'nyolcvan' },
|
|
22
|
+
{ '70': 'hetven' },
|
|
23
|
+
{ '60': 'hatvan' },
|
|
24
|
+
{ '50': 'ötven' },
|
|
25
|
+
{ '40': 'negyven' },
|
|
26
|
+
{ '30': 'harminc' },
|
|
27
|
+
{ '29': 'huszonkilenc' },
|
|
28
|
+
{ '28': 'huszonnyolc' },
|
|
29
|
+
{ '27': 'huszonhét' },
|
|
30
|
+
{ '26': 'huszonhat' },
|
|
31
|
+
{ '25': 'huszonöt' },
|
|
32
|
+
{ '24': 'huszonnégy' },
|
|
33
|
+
{ '23': 'huszonhárom' },
|
|
34
|
+
{ '22': 'huszonkettő' },
|
|
35
|
+
{ '21': 'huszonegy' },
|
|
36
|
+
{ '20': 'húsz' },
|
|
37
|
+
{ '19': 'tizenkilenc' },
|
|
38
|
+
{ '18': 'tizennyolc' },
|
|
39
|
+
{ '17': 'tizenhét' },
|
|
40
|
+
{ '16': 'tizenhat' },
|
|
41
|
+
{ '15': 'tizenöt' },
|
|
42
|
+
{ '14': 'tizennégy' },
|
|
43
|
+
{ '13': 'tizenhárom' },
|
|
44
|
+
{ '12': 'tizenkettő' },
|
|
45
|
+
{ '11': 'tizenegy' },
|
|
46
|
+
{ '10': 'tíz' },
|
|
47
|
+
{ '9': 'kilenc' },
|
|
48
|
+
{ '8': 'nyolc' },
|
|
49
|
+
{ '7': 'hét' },
|
|
50
|
+
{ '6': 'hat' },
|
|
51
|
+
{ '5': 'öt' },
|
|
52
|
+
{ '4': 'négy' },
|
|
53
|
+
{ '3': 'három' },
|
|
54
|
+
{ '2': 'kettő' },
|
|
55
|
+
{ '1': 'egy' },
|
|
56
|
+
{ '0': 'nulla' }
|
|
57
|
+
];
|
|
58
|
+
this.zero = 'nulla';
|
|
59
|
+
}
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
tensToCardinal(number) {
|
|
60
62
|
if (this.getValueFromCards(number)) {
|
|
61
63
|
return this.getValueFromCards(number);
|
|
62
64
|
} else {
|
|
@@ -64,9 +66,9 @@ export default function () {
|
|
|
64
66
|
const units = number % 10;
|
|
65
67
|
return this.getValueFromCards(tens * 10) + this.toCardinal(units);
|
|
66
68
|
}
|
|
67
|
-
}
|
|
69
|
+
}
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
hundredsToCardinal(number) {
|
|
70
72
|
const hundreds = Math.floor(number / 100);
|
|
71
73
|
let prefix = 'száz';
|
|
72
74
|
if (hundreds != 1) {
|
|
@@ -74,9 +76,9 @@ export default function () {
|
|
|
74
76
|
}
|
|
75
77
|
const postfix = this.toCardinal(number % 100, '');
|
|
76
78
|
return prefix + postfix;
|
|
77
|
-
}
|
|
79
|
+
}
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
thousandsToCardinal(number) {
|
|
80
82
|
const thousands = Math.floor(number / 1000);
|
|
81
83
|
let prefix = 'ezer';
|
|
82
84
|
if (thousands != 1) {
|
|
@@ -85,9 +87,9 @@ export default function () {
|
|
|
85
87
|
let postfix = this.toCardinal(number % 1000, '');
|
|
86
88
|
let middle = (number <= 2000 || postfix === '') ? '' : '-';
|
|
87
89
|
return prefix + middle + postfix;
|
|
88
|
-
}
|
|
90
|
+
}
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
bigNumberToCardinal(number) {
|
|
91
93
|
const numberLength = String(number).length;
|
|
92
94
|
let digits = (numberLength % 3 !== 0) ? numberLength : numberLength - 2;
|
|
93
95
|
let exp = 10 ** (Math.floor(digits / 3) * 3);
|
|
@@ -95,9 +97,9 @@ export default function () {
|
|
|
95
97
|
let rest = this.toCardinal(number % exp, '');
|
|
96
98
|
let postfix = (rest !== '') ? ('-' + rest) : '';
|
|
97
99
|
return prefix + this.getValueFromCards(exp) + postfix;
|
|
98
|
-
}
|
|
100
|
+
}
|
|
99
101
|
|
|
100
|
-
|
|
102
|
+
toCardinal(number, zero = this.zero) {
|
|
101
103
|
let words = '';
|
|
102
104
|
|
|
103
105
|
if (number == 0) {
|
|
@@ -117,5 +119,9 @@ export default function () {
|
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
return words;
|
|
120
|
-
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default function(n) {
|
|
126
|
+
return new N2WordsHU().floatToCardinal(n);
|
|
121
127
|
}
|
package/lib/i18n/ID.mjs
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import N2WordsAbs from '../classes/N2WordsAbs.mjs';
|
|
2
|
+
|
|
3
|
+
export class N2WordsID extends N2WordsAbs {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
|
|
7
|
+
this.negativeWord = 'min';
|
|
8
|
+
this.separatorWord = 'koma';
|
|
9
|
+
this.zero = 'nol';
|
|
10
|
+
this.base = {
|
|
11
|
+
0: [],
|
|
12
|
+
1: ['satu'],
|
|
13
|
+
2: ['dua'],
|
|
14
|
+
3: ['tiga'],
|
|
15
|
+
4: ['empat'],
|
|
16
|
+
5: ['lima'],
|
|
17
|
+
6: ['enam'],
|
|
18
|
+
7: ['tujuh'],
|
|
19
|
+
8: ['delapan'],
|
|
20
|
+
9: ['sembilan'],
|
|
21
|
+
};
|
|
22
|
+
this.thousands = {
|
|
23
|
+
3: 'ribu', // 10^3
|
|
24
|
+
6: 'juta', // 10^6
|
|
25
|
+
9: 'miliar', // 10^9
|
|
26
|
+
12: 'triliun',
|
|
27
|
+
15: 'kuadriliun',
|
|
28
|
+
18: 'kuantiliun',
|
|
29
|
+
21: 'sekstiliun',
|
|
30
|
+
24: 'septiliun',
|
|
31
|
+
27: 'oktiliun',
|
|
32
|
+
30: 'noniliun',
|
|
33
|
+
33: 'desiliun',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
splitBy3(number) {
|
|
38
|
+
// Split to groups of 3 numbers: 1234567 -> [['1'], ['234'], ['567']]
|
|
39
|
+
let blocks = [];
|
|
40
|
+
let strNumber = String(number);
|
|
41
|
+
let length = strNumber.length;
|
|
42
|
+
let firstBlock;
|
|
43
|
+
|
|
44
|
+
if (length < 3) {
|
|
45
|
+
blocks.push([strNumber]);
|
|
46
|
+
} else {
|
|
47
|
+
let firstBlockLength = length % 3;
|
|
48
|
+
|
|
49
|
+
if (firstBlockLength > 0) {
|
|
50
|
+
firstBlock = [strNumber.slice(0, firstBlockLength)];
|
|
51
|
+
blocks.push(firstBlock);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
for (let i = firstBlockLength; i < length; i += 3) {
|
|
55
|
+
let nextBlock = [strNumber.slice(i, i + 3)];
|
|
56
|
+
blocks.push(nextBlock);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return blocks;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
spell(blocks) {
|
|
63
|
+
// Example:
|
|
64
|
+
// blocks: [['1'], ['234']]
|
|
65
|
+
// return: [['1', ['satu']], ['234', ['dua', 'ratus', 'tiga', 'puluh', ['empat']]]]
|
|
66
|
+
let wordBlocks = [];
|
|
67
|
+
let spelling;
|
|
68
|
+
let firstBlock = blocks[0];
|
|
69
|
+
if (firstBlock[0].length === 1) {
|
|
70
|
+
if (firstBlock[0] === '0') {
|
|
71
|
+
spelling = ['nol'];
|
|
72
|
+
} else {
|
|
73
|
+
spelling = this.base[parseInt(firstBlock[0])];
|
|
74
|
+
}
|
|
75
|
+
} else if (firstBlock[0].length === 2) {
|
|
76
|
+
spelling = this.getTens(firstBlock[0]);
|
|
77
|
+
} else {
|
|
78
|
+
spelling = this.getHundreds(
|
|
79
|
+
firstBlock[0][0]
|
|
80
|
+
).concat(this.getTens(firstBlock[0].slice(1, 3)));
|
|
81
|
+
}
|
|
82
|
+
wordBlocks = wordBlocks.concat([[firstBlock[0], spelling]]);
|
|
83
|
+
for (let i = 1; i < blocks.length; i++) {
|
|
84
|
+
let block = blocks[i];
|
|
85
|
+
spelling = this.getHundreds(block[0][0]).concat(
|
|
86
|
+
this.getTens(block[0].slice(1, 3))
|
|
87
|
+
);
|
|
88
|
+
block = block.concat([spelling]);
|
|
89
|
+
wordBlocks = wordBlocks.concat([block]);
|
|
90
|
+
}
|
|
91
|
+
return wordBlocks;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
getHundreds(number) { // 'ratus'
|
|
95
|
+
if (number === '1') {
|
|
96
|
+
return ['seratus'];
|
|
97
|
+
} else if (number === '0') {
|
|
98
|
+
return [];
|
|
99
|
+
} else {
|
|
100
|
+
return this.base[parseInt(number)].concat(['ratus']);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getTens(number) { // 'puluh'
|
|
105
|
+
if (number[0] === '1') {
|
|
106
|
+
if (number[1] === '0') {
|
|
107
|
+
return ['sepuluh'];
|
|
108
|
+
} else if (number[1] === '1') {
|
|
109
|
+
return ['sebelas'];
|
|
110
|
+
} else {
|
|
111
|
+
return this.base[parseInt(number[1])].concat(['belas']);
|
|
112
|
+
}
|
|
113
|
+
} else if (number[0] === '0') {
|
|
114
|
+
return this.base[parseInt(number[1])];
|
|
115
|
+
} else {
|
|
116
|
+
return this.base[parseInt(number[0])].concat(['puluh']).concat(
|
|
117
|
+
[this.base[parseInt(number[1])]]
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
join(wordBlocks) {
|
|
123
|
+
let wordList = [];
|
|
124
|
+
let length = wordBlocks.length - 1;
|
|
125
|
+
let firstBlock = [wordBlocks[0]];
|
|
126
|
+
let start = 0;
|
|
127
|
+
if (length === 1 && firstBlock[0][0] === '1') {
|
|
128
|
+
wordList.push('seribu');
|
|
129
|
+
start = 1;
|
|
130
|
+
}
|
|
131
|
+
for (let i = start; i < length + 1; i++) {
|
|
132
|
+
wordList = wordList.concat(wordBlocks[i][1]);
|
|
133
|
+
if (!wordBlocks[i][1].length) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (i === length) {
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
wordList = wordList.concat([this.thousands[(length - i) * 3]]);
|
|
140
|
+
}
|
|
141
|
+
return wordList.join(' ');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
toCardinal(number) {
|
|
145
|
+
return this.join(
|
|
146
|
+
this.spell(
|
|
147
|
+
this.splitBy3(number)
|
|
148
|
+
)
|
|
149
|
+
).trim();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default function (n) {
|
|
154
|
+
return new N2WordsID().floatToCardinal(n);
|
|
155
|
+
}
|
package/lib/i18n/IT.mjs
CHANGED
|
@@ -1,65 +1,67 @@
|
|
|
1
1
|
import N2WordsBase from '../classes/N2WordsBase.mjs';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export class N2WordsIT extends N2WordsBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
this.negativeWord = 'meno';
|
|
8
|
+
this.separatorWord = 'virgola';
|
|
9
|
+
this.zero = 'zero';
|
|
10
|
+
this.cardinalWords = [
|
|
11
|
+
this.zero, 'uno', 'due', 'tre', 'quattro', 'cinque', 'sei', 'sette', 'otto',
|
|
12
|
+
'nove', 'dieci', 'undici', 'dodici', 'tredici', 'quattordici', 'quindici',
|
|
13
|
+
'sedici', 'diciassette', 'diciotto', 'diciannove',
|
|
14
|
+
];
|
|
15
|
+
this.strTens = {'2': 'venti', '3': 'trenta', '4': 'quaranta', '6': 'sessanta'};
|
|
16
|
+
this.exponentPrefixes = [this.zero, 'm', 'b', 'tr', 'quadr', 'quint', 'sest', 'sett', 'ott', 'nov', 'dec'];
|
|
17
|
+
}
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
accentuate(string) {
|
|
18
20
|
const splittedString = string.split(' ');
|
|
19
21
|
|
|
20
|
-
const result = splittedString.map(
|
|
22
|
+
const result = splittedString.map(word => {
|
|
21
23
|
if (word.slice(-3) == 'tre' && word.length > 3) return word.replace(/tré/g, 'tre').slice(0, -3) + 'tré';
|
|
22
24
|
else return word.replace(/tré/g, 'tre');
|
|
23
25
|
});
|
|
24
26
|
return result.join(' ');
|
|
25
|
-
}
|
|
27
|
+
}
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
if (numberToString == this.
|
|
29
|
+
omitIfZero(numberToString) {
|
|
30
|
+
if (numberToString == this.zero) {
|
|
29
31
|
return '';
|
|
30
32
|
} else {
|
|
31
33
|
return numberToString;
|
|
32
34
|
}
|
|
33
|
-
}
|
|
35
|
+
}
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
phoneticContraction(string) {
|
|
36
38
|
return string.replace(/oo/g, 'o').replace(/ao/g, 'o').replace(/io/g, 'o').replace(/au/g, 'u').replace(/iu/g, 'u');
|
|
37
|
-
}
|
|
39
|
+
}
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
tensToCardinal(number) {
|
|
40
42
|
const tens = Math.floor(number / 10);
|
|
41
43
|
const units = number % 10;
|
|
42
44
|
let prefix;
|
|
43
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
44
|
-
prefix =
|
|
45
|
+
if (Object.prototype.hasOwnProperty.call(this.strTens, tens)) {
|
|
46
|
+
prefix = this.strTens[tens];
|
|
45
47
|
} else {
|
|
46
|
-
prefix =
|
|
48
|
+
prefix = this.cardinalWords[tens].slice(0, -1) + 'anta';
|
|
47
49
|
}
|
|
48
|
-
const postfix = this.omitIfZero(
|
|
50
|
+
const postfix = this.omitIfZero(this.cardinalWords[units]);
|
|
49
51
|
return this.phoneticContraction(prefix + postfix);
|
|
50
|
-
}
|
|
52
|
+
}
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
hundredsToCardinal(number) {
|
|
53
55
|
const hundreds = Math.floor(number / 100);
|
|
54
56
|
let prefix = 'cento';
|
|
55
57
|
if (hundreds != 1) {
|
|
56
|
-
prefix =
|
|
58
|
+
prefix = this.cardinalWords[hundreds] + prefix;
|
|
57
59
|
}
|
|
58
60
|
const postfix = this.omitIfZero(this.toCardinal(number % 100));
|
|
59
61
|
return this.phoneticContraction(prefix + postfix);
|
|
60
|
-
}
|
|
62
|
+
}
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
thousandsToCardinal(number) {
|
|
63
65
|
const thousands = Math.floor(number / 1000);
|
|
64
66
|
let prefix;
|
|
65
67
|
if (thousands == 1) {
|
|
@@ -69,18 +71,18 @@ export default function() {
|
|
|
69
71
|
}
|
|
70
72
|
const postfix = this.omitIfZero(this.toCardinal(number % 1000));
|
|
71
73
|
return prefix + postfix;
|
|
72
|
-
}
|
|
74
|
+
}
|
|
73
75
|
|
|
74
|
-
|
|
75
|
-
const prefix =
|
|
76
|
+
exponentLengthToString(exponentLength) {
|
|
77
|
+
const prefix = this.exponentPrefixes[Math.floor(exponentLength / 6)];
|
|
76
78
|
if (exponentLength % 6 == 0) {
|
|
77
79
|
return prefix + 'ilione';
|
|
78
80
|
} else {
|
|
79
81
|
return prefix + 'iliardo';
|
|
80
82
|
}
|
|
81
|
-
}
|
|
83
|
+
}
|
|
82
84
|
|
|
83
|
-
|
|
85
|
+
bigNumberToCardinal(number) {
|
|
84
86
|
const digits = Array.from(String(number));
|
|
85
87
|
const predigits = (digits.length % 3 == 0) ? 3 : digits.length % 3;
|
|
86
88
|
const multiplier = digits.slice(0, predigits); // first `predigits` elements
|
|
@@ -93,7 +95,7 @@ export default function() {
|
|
|
93
95
|
prefix = this.toCardinal(parseInt(multiplier.join('')));
|
|
94
96
|
infix = ' ' + infix.slice(0, -1) + 'i'; // without last element
|
|
95
97
|
}
|
|
96
|
-
const isSetsEqual = (a, b) => a.size === b.size && [...a].every(
|
|
98
|
+
const isSetsEqual = (a, b) => a.size === b.size && [...a].every(value => b.has(value));
|
|
97
99
|
if (!isSetsEqual(new Set(exponent), new Set(['0']))) {
|
|
98
100
|
postfix = this.toCardinal(parseInt(exponent.join('')));
|
|
99
101
|
if (postfix.includes(' e ')) {
|
|
@@ -105,13 +107,13 @@ export default function() {
|
|
|
105
107
|
postfix = '';
|
|
106
108
|
}
|
|
107
109
|
return prefix + infix + postfix;
|
|
108
|
-
}
|
|
110
|
+
}
|
|
109
111
|
|
|
110
|
-
|
|
112
|
+
toCardinal(number) {
|
|
111
113
|
let words = '';
|
|
112
114
|
|
|
113
115
|
if (number < 20) {
|
|
114
|
-
words =
|
|
116
|
+
words = this.cardinalWords[number];
|
|
115
117
|
} else if (number < 100) {
|
|
116
118
|
words = this.tensToCardinal(number);
|
|
117
119
|
} else if (number < 1000) {
|
|
@@ -123,5 +125,9 @@ export default function() {
|
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
return this.accentuate(words);
|
|
126
|
-
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export default function(n) {
|
|
132
|
+
return new N2WordsIT().floatToCardinal(n);
|
|
127
133
|
}
|
package/lib/i18n/KO.mjs
CHANGED
|
@@ -1,39 +1,48 @@
|
|
|
1
1
|
import N2WordsBase from '../classes/N2WordsBase.mjs';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export class N2WordsKO 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
|
-
|
|
7
|
+
this.negativeWord = '마이너스';
|
|
8
|
+
this.separatorWord = '점';
|
|
9
|
+
this.zero = '영';
|
|
10
|
+
this.cards = [
|
|
11
|
+
{ '10000000000000000000000000000': '양' },
|
|
12
|
+
{ '1000000000000000000000000': '자' },
|
|
13
|
+
{ '100000000000000000000': '해' },
|
|
14
|
+
{ '10000000000000000': '경' },
|
|
15
|
+
{ '1000000000000': '조' },
|
|
16
|
+
{ '100000000': '억' },
|
|
17
|
+
{ '10000': '만' },
|
|
18
|
+
{ '1000': '천' },
|
|
19
|
+
{ '100': '백' },
|
|
20
|
+
{ '10': '십' },
|
|
21
|
+
{ '9': '구' },
|
|
22
|
+
{ '8': '팔' },
|
|
23
|
+
{ '7': '칠' },
|
|
24
|
+
{ '6': '육' },
|
|
25
|
+
{ '5': '오' },
|
|
26
|
+
{ '4': '사' },
|
|
27
|
+
{ '3': '삼' },
|
|
28
|
+
{ '2': '이' },
|
|
29
|
+
{ '1': '일' },
|
|
30
|
+
{ '0': '영' }
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
merge(lPair, rPair) {
|
|
35
|
+
const lText = Object.keys(lPair)[0];
|
|
36
|
+
const rText = Object.keys(rPair)[0];
|
|
37
|
+
const lNum = parseInt(Object.values(lPair)[0]);
|
|
38
|
+
const rNum = parseInt(Object.values(rPair)[0]);
|
|
39
|
+
if (lNum == 1 && rNum <= 10000) return { [rText]: rNum };
|
|
40
|
+
else if (10000 > lNum && lNum > rNum) return { [`${lText}${rText}`]: lNum + rNum };
|
|
41
|
+
else if (lNum >= 10000 && lNum > rNum) return { [`${lText} ${rText}`]: lNum + rNum };
|
|
42
|
+
else return { [`${lText}${rText}`]: lNum * rNum };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default function(n) {
|
|
47
|
+
return new N2WordsKO().floatToCardinal(n);
|
|
39
48
|
}
|