https://github.com/a-x-/cyrillic-inflector
cyrillic inflector (count, one, zero, some, many)
https://github.com/a-x-/cyrillic-inflector
cyrillic format inflector intl number units
Last synced: 3 months ago
JSON representation
cyrillic inflector (count, one, zero, some, many)
- Host: GitHub
- URL: https://github.com/a-x-/cyrillic-inflector
- Owner: a-x-
- License: mit
- Created: 2017-05-09T13:12:09.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-07-13T16:31:56.000Z (almost 2 years ago)
- Last Synced: 2025-01-11T01:58:21.417Z (5 months ago)
- Topics: cyrillic, format, inflector, intl, number, units
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/cyrillic-inflector
- Size: 168 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cyrillic-inflector [](https://travis-ci.org/a-x-/cyrillic-inflector)
cyrillic inflector (count, one, zero, some, many)```js
import inflect from 'cyrillic-inflector';inflect(0, { zero: 'no calls', one: '{} call' }) // --> no calls
const loadPhrase = inflect({
zero: 'Файлы не загружены',
one: 'Загружен {} файл',
some: 'Загружено {} файла',
many: 'Загружено {} файлов'
});
test('complex zero', t => {
t.is(loadPhrase(0), 'Файлы не загружены');
});
test('complex one', t => {
t.is(loadPhrase(31), 'Загружен 31 файл');
});
test('complex some', t => {
t.is(loadPhrase(5564), 'Загружено 5564 файла');
});
test('complex many', t => {
t.is(loadPhrase(100500), 'Загружено 100500 файлов');
});
```See test.js for more typical and edge cases
## TODO
- [ ] find alternative solutions## Relative libs
- [messageformat]
- genders
- multiple variables- [petrovich]
- automatic cyrillic inflector: ex-usser full names
[messageformat]: https://github.com/messageformat/messageformat.js
[petrovich]: https://github.com/petrovich/petrovich-js