Skip to content

Commit 55d04e7

Browse files
authored
Merge pull request #53 from taras-ua/master to develop
Add support for Ukrainian
2 parents 062bb90 + 9203212 commit 55d04e7

File tree

6 files changed

+697
-134
lines changed

6 files changed

+697
-134
lines changed

README.md

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Currently supported languages are:
5252
| Arabic | `ar` |
5353
| Turkish | `tr` |
5454
| English (Indian) | `enIndian` |
55+
| Ukrainian | `uk` |
5556

5657

5758
```javascript
@@ -62,10 +63,15 @@ writtenNumber(1234, {lang: 'fr'}); // => 'mille deux cent trente-quatre'
6263
writtenNumber(1234, {lang: 'ar'}); // => 'ألف ومائتان وأربعة وثلاثون'
6364
writtenNumber(1234, {lang: 'eo'}); // => 'mil ducent tridek kvar'
6465
writtenNumber(1234, {lang: 'vi'}); // => 'một ngàn hai trăm và ba mươi bốn'
66+
writtenNumber(1234, { lang: 'uk' }); // => 'одна тисяча двісті тридцять чотири'
6567
```
6668

69+
6770
## 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.
71+
Each language has it's own unique grammar exceptions. You can create your own
72+
language.json file in the folder "i18n" and give writtenNumber support for it. I
73+
don't think the current scheme and logic cover all the cases, but may be cover
74+
some.
6975

7076
##### useLongScale:
7177
'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.
@@ -85,6 +91,18 @@ Example: 1125 -> ألف **و**مائة **و**خمسة **و**عشرون
8591
##### base:
8692
Base cardinals numbers. Numbers that have unique names and are used to build others.
8793

94+
##### alternativeBase:
95+
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`.
96+
97+
```json
98+
"alternativeBase": {
99+
"feminine": {
100+
"1": "одна",
101+
"2": "дві"
102+
}
103+
}
104+
```
105+
88106
##### units:
89107
Number units.
90108
It can be:
@@ -96,10 +114,42 @@ It can be:
96114
"plural": "millones"
97115
}
98116
```
117+
118+
- Object with `few` word form.
119+
120+
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`.
121+
122+
```json
123+
{
124+
"singular": "мільйон",
125+
"few": "мільйони",
126+
"plural": "мільйонів",
127+
...
128+
}
129+
```
130+
131+
- Object with `useAlternativeBase`.
132+
133+
Selects an `alternativeBase` name which this unit should prefer over the default `base` if possible.
134+
135+
```json
136+
{
137+
"singular": "тисяча",
138+
"few": "тисячі",
139+
"plural": "тисяч",
140+
"useAlternativeBase": "feminine"
141+
...
142+
}
143+
```
144+
145+
99146
- Object with `useBaseInstead` exception.
147+
100148
In some languages like spanish and arabic, specific units like "ciento", use the base cardinal number instead.
149+
101150
- Object with `useBaseException`: You can also specify with which unit (1 to 9) you don't
102151
want use the base cardinal instead and use the regular behaviour:
152+
103153
```json
104154
{
105155
"singular": "ciento",
@@ -129,6 +179,21 @@ numbers wioth trailing numbers other than 0, for example "deux cents" and "deux
129179
- Object with `restrictedPlural` boolean:
130180
If plural is used only for numbers from 3 to 10 , but the singular form is used if the number is older than 11.
131181

182+
- Object with `useSingularEnding` exception and `useFewEnding` exception.
183+
184+
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.
185+
186+
```json
187+
{
188+
"singular": "мільйон",
189+
"few": "мільйони",
190+
"plural": "мільйонів",
191+
"useSingularEnding": true,
192+
"useFewEnding": true,
193+
"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]
194+
}
195+
```
196+
132197
##### unitExceptions:
133198
Sometimes grammar exceptions affect the base cardinal joined to the unit. You
134199
can set specific exceptions to any base cardinal number.

0 commit comments

Comments
 (0)