Skip to content

Commit a3c04a1

Browse files
committed
Add support for Ukrainian
1 parent 08336d9 commit a3c04a1

File tree

6 files changed

+578
-26
lines changed

6 files changed

+578
-26
lines changed

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Currently supported languages are:
4747
- Vietnamese `lang = "vi"`
4848
- Turkish `lang = "tr"`
4949
- English (Indian) `lang = "enIndian"`
50+
- Ukrainian `lang = "uk"`
5051

5152
### Spanish Example
5253
```javascript
@@ -84,6 +85,12 @@ var writtenNumber = require('written-number');
8485
writtenNumber(1234, { lang: 'vi' }); // => 'một ngàn hai trăm và ba mươi bốn'
8586
```
8687

88+
### Ukrainian Example
89+
```javascript
90+
var writtenNumber = require('written-number');
91+
writtenNumber(1234, { lang: 'uk' }); // => 'одна тисяча двісті тридцять чотири'
92+
```
93+
8794
## Options
8895
Property | Value
8996
-------------- | -------------
@@ -113,6 +120,18 @@ Example: 1234 -> one thousand two hundred **and** thirty-four
113120
Base cardinals numbers. Numbers that have unique names and are used to build
114121
others.
115122

123+
##### alternativeBase:
124+
Alternative versions of base cardinals numbers for usage with specific units (ex. thousands in Ukrainian use feminine form of base cardinal numbers). These bases will be treated as an extension for the default `base`.
125+
126+
```json
127+
"alternativeBase": {
128+
"feminine": {
129+
"1": "одна",
130+
"2": "дві"
131+
}
132+
}
133+
```
134+
116135
##### units:
117136
Number units.
118137
It can be:
@@ -128,7 +147,35 @@ It can be:
128147
}
129148
```
130149

150+
- Object with `few` word form.
151+
152+
In some languages like Ukrainian, there are specific unit forms for values from 2 (including) to 4 (including). This forms can be specified with `few`.
153+
154+
```json
155+
{
156+
"singular": "мільйон",
157+
"few": "мільйони",
158+
"plural": "мільйонів",
159+
...
160+
}
161+
```
162+
163+
- Object with `useAlternativeBase`.
164+
165+
Selects an `alternativeBase` name which this unit should prefer over the default `base` if possible.
166+
167+
```json
168+
{
169+
"singular": "тисяча",
170+
"few": "тисячі",
171+
"plural": "тисяч",
172+
"useAlternativeBase": "feminine"
173+
...
174+
}
175+
```
176+
131177
- Object with `useBaseInstead` exception.
178+
132179
In some languages like spanish, specific units like "ciento", use the base
133180
cardinal number instead.
134181

@@ -169,6 +216,21 @@ numbers wioth trailing numbers other than 0, for example "deux cents" and "deux
169216
}
170217
```
171218

219+
- Object with `useSingularEnding` exception and `useFewEnding` exception.
220+
221+
In some languages like Ukrainian, singular form of the unit is also used for any values that end with 1 (21, 31, 14, ..., 101, ...) and "few" form of the unit is also used for any values that end with 2, 3 and 4 (22, 33, 44, ..., 104, ...). The `avoidEndingRules` exception provides values (1 to 999) where these rules must be ignored and the plural form must be used instead.
222+
223+
```json
224+
{
225+
"singular": "мільйон",
226+
"few": "мільйони",
227+
"plural": "мільйонів",
228+
"useSingularEnding": true,
229+
"useFewEnding": true,
230+
"avoidEndingRules": [11, 12, 13, 14, 111, 112, 113, 114, 211, 212, 213, 214, 311, 312, 313, 314, 411, 412, 413, 414, 511, 512, 513, 514, 611, 612, 613, 614, 711, 712, 713, 714, 811, 812, 813, 814, 911, 912, 913, 914]
231+
}
232+
```
233+
172234
##### unitExceptions:
173235
Sometimes grammar exceptions affect the base cardinal joined to the unit. You
174236
can set specific exceptions to any base cardinal number.

0 commit comments

Comments
 (0)