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
65
```
86
66
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.
67
+
## Configure your own language
68
+
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
69
99
70
##### 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.
71
+
'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
72
104
73
##### baseSeparator:
105
74
'String' that separates the base cardinal numbers.
@@ -109,148 +78,68 @@ Example: 29 -> twenty`-`eight. Spanish uses the conector " y ".
109
78
'String' that separates the units from the last base cardinal numbers.
110
79
Example: 1234 -> one thousand two hundred **and** thirty-four
111
80
81
+
##### allSeparator:
82
+
'String' that separates all cardinals, not only the last one.
83
+
Example: 1125 -> ألف **و**مائة **و**خمسة **و**عشرون
84
+
112
85
##### base:
113
-
Base cardinals numbers. Numbers that have unique names and are used to build
114
-
others.
86
+
Base cardinals numbers. Numbers that have unique names and are used to build others.
115
87
116
88
##### units:
117
89
Number units.
118
90
It can be:
119
91
- String
120
-
121
-
- Object normal flow. Give support to singular and plural units. English does
122
-
not need this, but spanish does.
123
-
92
+
- Object normal flow. Give support to singular, dual, and plural units. English does not need this, but spanish does.
124
93
```json
125
94
{
126
95
"singular": "millón",
127
96
"plural": "millones"
128
97
}
129
98
```
130
-
131
99
- 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
-
100
+
In some languages like spanish and arabic, specific units like "ciento", use the base cardinal number instead.
101
+
- Object with `useBaseException`: You can also specify with which unit (1 to 9) you don't
102
+
want use the base cardinal instead and use the regular behaviour:
138
103
```json
139
104
{
140
105
"singular": "ciento",
141
106
"useBaseInstead": true,
142
107
"useBaseException": [1]
143
108
}
144
109
```
145
-
146
-
- Object with `avoidPrefixException` exception.
147
-
110
+
- Object with `avoidPrefixException` exception:
148
111
In some languages like spanish, specific units like "mil" does not use the base
149
112
cardinal number prefix for unit 1.
150
-
151
113
```json
152
114
{
153
115
"singular": "mil",
154
116
"avoidPrefixException": [1]
155
117
}
156
118
```
157
-
158
-
159
119
- Object with `avoidInNumberPlural` exception.
160
-
161
120
In some languages like french, specific units like "cent" does not use the plural form inside of
162
121
numbers wioth trailing numbers other than 0, for example "deux cents" and "deux cent trois".
163
-
164
122
```json
165
123
{
166
124
"singular": "cent",
167
125
"plural": "cents",
168
126
"avoidInNumberPlural": true
169
127
}
170
128
```
129
+
- Object with `restrictedPlural` boolean:
130
+
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
131
172
132
##### unitExceptions:
173
133
Sometimes grammar exceptions affect the base cardinal joined to the unit. You
174
134
can set specific exceptions to any base cardinal number.
175
-
176
135
Spanish example:
177
-
178
136
```
179
137
Without Exception (Wrong): 1232000 -> **uno** millón doscientos treinta y dos mil
180
-
```
181
-
182
-
```
183
138
With Exception: 1232000 -> **un** millón doscientos treinta y dos mil
184
139
```
185
140
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
141
## 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`.
142
+
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
143
254
144
## 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.
145
+
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