You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
writtenNumber(1234, { lang:'vi' }); // => 'một ngàn hai trăm và ba mươi bốn'
85
-
```
86
-
87
-
## Options
88
-
Property | Value
89
-
-------------- | -------------
90
-
noAnd | false
91
-
lang | 'en'
92
-
93
-
### Configure your own language
94
-
Each language has it's own unique grammar exceptions. You can create your own
95
-
language.json file in the folder "i18n" and give writtenNumber support for it. I
96
-
don't think the current scheme and logic cover all the cases, but may be cover
97
-
some.
65
+
## Configure your own language
66
+
Each language has it's own unique grammar exceptions. You can create your own language.json file in the folder "i18n" and give writtenNumber support for it. I don't think the current scheme and logic cover all the cases, but may be cover some.
98
67
99
68
##### useLongScale:
100
-
'Boolean' that indicates if it use [long or short
101
-
scale](http://en.wikipedia.org/wiki/Long_and_short_scales). This differs the
102
-
meaning of the words `billion`, `trillion` and so on.
69
+
'Boolean' that indicates if it use [long or short scale](http://en.wikipedia.org/wiki/Long_and_short_scales). This differs the meaning of the words `billion`, `trillion` and so on.
103
70
104
71
##### baseSeparator:
105
72
'String' that separates the base cardinal numbers.
@@ -109,148 +76,68 @@ Example: 29 -> twenty`-`eight. Spanish uses the conector " y ".
109
76
'String' that separates the units from the last base cardinal numbers.
110
77
Example: 1234 -> one thousand two hundred **and** thirty-four
111
78
79
+
##### allSeparator:
80
+
'String' that separates all cardinals, not only the last one.
81
+
Example: 1125 -> ألف **و**مائة **و**خمسة **و**عشرون
82
+
112
83
##### base:
113
-
Base cardinals numbers. Numbers that have unique names and are used to build
114
-
others.
84
+
Base cardinals numbers. Numbers that have unique names and are used to build others.
115
85
116
86
##### units:
117
87
Number units.
118
88
It can be:
119
89
- String
120
-
121
-
- Object normal flow. Give support to singular and plural units. English does
122
-
not need this, but spanish does.
123
-
90
+
- Object normal flow. Give support to singular, dual, and plural units. English does not need this, but spanish does.
124
91
```json
125
92
{
126
93
"singular": "millón",
127
94
"plural": "millones"
128
95
}
129
96
```
130
-
131
97
- Object with `useBaseInstead` exception.
132
-
In some languages like spanish, specific units like "ciento", use the base
133
-
cardinal number instead.
134
-
135
-
With `useBaseException` you can also specify with which unit (1 to 9) you don't
136
-
want use the base cardinal instead and use the regular behaviour.
137
-
98
+
In some languages like spanish and arabic, specific units like "ciento", use the base cardinal number instead.
99
+
- Object with `useBaseException`: You can also specify with which unit (1 to 9) you don't
100
+
want use the base cardinal instead and use the regular behaviour:
138
101
```json
139
102
{
140
103
"singular": "ciento",
141
104
"useBaseInstead": true,
142
105
"useBaseException": [1]
143
106
}
144
107
```
145
-
146
-
- Object with `avoidPrefixException` exception.
147
-
108
+
- Object with `avoidPrefixException` exception:
148
109
In some languages like spanish, specific units like "mil" does not use the base
149
110
cardinal number prefix for unit 1.
150
-
151
111
```json
152
112
{
153
113
"singular": "mil",
154
114
"avoidPrefixException": [1]
155
115
}
156
116
```
157
-
158
-
159
117
- Object with `avoidInNumberPlural` exception.
160
-
161
118
In some languages like french, specific units like "cent" does not use the plural form inside of
162
119
numbers wioth trailing numbers other than 0, for example "deux cents" and "deux cent trois".
163
-
164
120
```json
165
121
{
166
122
"singular": "cent",
167
123
"plural": "cents",
168
124
"avoidInNumberPlural": true
169
125
}
170
126
```
127
+
- Object with `restrictedPlural` boolean:
128
+
If plural is used only for numbers from 3 to 10 , but the singular form is used if the number is older than 11.
171
129
172
130
##### unitExceptions:
173
131
Sometimes grammar exceptions affect the base cardinal joined to the unit. You
174
132
can set specific exceptions to any base cardinal number.
175
-
176
133
Spanish example:
177
-
178
134
```
179
135
Without Exception (Wrong): 1232000 -> **uno** millón doscientos treinta y dos mil
180
-
```
181
-
182
-
```
183
136
With Exception: 1232000 -> **un** millón doscientos treinta y dos mil
184
137
```
185
138
186
-
### English configuration example
187
-
```json
188
-
{
189
-
"useLongScale": false,
190
-
"baseSeparator": "-",
191
-
"unitSeparator": "and ",
192
-
"base": {
193
-
"0": "zero",
194
-
"1": "one",
195
-
"2": "two",
196
-
"3": "three",
197
-
...
198
-
"90": "ninety"
199
-
},
200
-
"units" : [
201
-
"hundred",
202
-
"thousand",
203
-
"million",
204
-
"billion",
205
-
"trillion",
206
-
...
207
-
"quindecillion"
208
-
],
209
-
"unitExceptions": []
210
-
}
211
-
```
212
-
213
-
### Spanish configuration example
214
-
```json
215
-
{
216
-
"useLongScale": true,
217
-
"baseSeparator": " y ",
218
-
"unitSeparator": "",
219
-
"base": {
220
-
"0": "cero",
221
-
"1": "uno",
222
-
"2": "dos",
223
-
"3": "tres",
224
-
...
225
-
"1000": "mil"
226
-
},
227
-
"unitExceptions": {
228
-
"1": "un"
229
-
},
230
-
"units" : [
231
-
{
232
-
"singular": "ciento",
233
-
"useBaseInstead": true,
234
-
"useBaseException": [1]
235
-
},
236
-
{
237
-
"singular": "mil",
238
-
"avoidPrefixException": [1]
239
-
},
240
-
{
241
-
"singular": "millón",
242
-
"plural": "millones"
243
-
},
244
-
...
245
-
]
246
-
}
247
-
```
248
-
249
139
## Contributing
250
-
Do your changes and submit a PR. If you've write access and want to bump the
251
-
version, run `mversion [major|minor|patch] -m`. That'll bump both `bower.json`
252
-
and `package.json`.
140
+
Do your changes and submit a PR. If you've write access and want to bump the version, run `mversion [major|minor|patch] -m`. That'll bump both `bower.json` and `package.json`.
253
141
254
142
## License
255
-
This code is licensed under the MIT license for Pedro Tacla Yamada. For more
256
-
information, please refer to the [LICENSE](/LICENSE) file.
143
+
This code is licensed under the MIT license for Pedro Tacla Yamada. For more information, please refer to the [LICENSE](/LICENSE) file.
0 commit comments