1 | Helps you to decline words in **Russian**, **Ukrainian** and **English** languages.
|
2 |
|
3 | ## Installation
|
4 | `decline-word` is available via npm:
|
5 | ``` bash
|
6 | $ npm i decline-word
|
7 | ```
|
8 |
|
9 | ## Usage
|
10 | ### For **Russian** and **Ukrainian** languages.
|
11 | 1st parameter: **amount** of item(s)
|
12 | 2nd: main word **body** (unchangeable part of word for each form)
|
13 | 3nd (optional, dafault = `''`): word ending for **1 item**
|
14 | 4th (optional, dafault = `''`): word ending for **2 items**
|
15 | 5th (optional, dafault = `''`): word ending for **5 items**
|
16 | ``` js
|
17 | const declineWord = require('decline-word');
|
18 |
|
19 | console.log(12, declineWord(12, 'яблок', 'о', 'а')); // 12 яблок
|
20 | console.log(22, declineWord(22, 'яблок', 'о', 'а')); // 22 яблока
|
21 | console.log(159, declineWord(159, 'яблок', 'о', 'а')); // 159 яблок
|
22 | console.log(1151, declineWord(1151, 'яблок', 'о', 'а')); // 1151 яблоко
|
23 |
|
24 | console.log(1, declineWord(1, 'апельсин', '', 'и', 'ів')); // 1 апельсин
|
25 | console.log(11, declineWord(11, 'апельсин', '', 'и', 'ів')); // 11 апельсинів
|
26 | console.log(84, declineWord(84, 'апельсин', '', 'и', 'ів')); // 84 апельсини
|
27 | console.log(147, declineWord(147, 'апельсин', '', 'и', 'ів')); // 147 апельсинів
|
28 | ```
|
29 |
|
30 | ### For **English** language.
|
31 | There is some difference of default parameter values comparing with the Russian and Ukrainian languages.
|
32 | 1st parameter: **amount** of item(s)
|
33 | 2nd: main word **body** (unchangeable part of word for each form)
|
34 | 3nd (optional, dafault = `''`): word ending for **1 item**
|
35 | 4th (optional, dafault = `'s'`): word ending for **2 items**
|
36 | 5th (optional, dafault = `<4th parameter>`): word ending for **5 items**
|
37 | That is made for more convenience using with English words.
|
38 | ``` js
|
39 | const declineWord = require('decline-word');
|
40 |
|
41 | console.log(1, declineWord(1, 'door')); // 1 door
|
42 | console.log(10, declineWord(10, 'doors')); // 10 doors
|
43 |
|
44 | console.log(11, declineWord(11, 'hero', '', 'es')); // 11 heroes
|
45 | console.log(21, declineWord(21, 'hero', '', 'es')); // 21 hero
|
46 |
|
47 | console.log(5, declineWord(5, 'cand', 'y', 'ies')); // 5 candies
|
48 | console.log(101, declineWord(101, 'cand', 'y', 'ies')); // 101 candy
|
49 |
|
50 | // declineWord(31, 't', 'ooth', 'eeth') or...
|
51 | console.log(31, declineWord(31, '', 'tooth', 'teeth')); // 31 tooth
|
52 | console.log(32, declineWord(32, '', 'tooth', 'teeth')); // 32 teeth
|
53 | ```
|
54 |
|
55 | Your improve suggestions and bug reports are welcome any time.
|