0.0.1 • Published 2 years ago
slav-cases v0.0.1
slav-cases
A basic l10n library to help work with word cases
Usage
Instal with npm command:
npm install --save slav-cases
Then define a word cases
import { format } from 'slav-cases';
const man = format({
cases: {
nominative: 'człowiek',
dative: 'człowiekowi',
// ... other cases
}
})
// somewhere in the code
man.nominative() // -> 'człowiek'
man.dative() // -> 'człowiekowi'
Or define a times
const permission = format({
times: {
past: 'дозволено',
present: 'дозволяти',
future: 'буде дозволено',
}
})
// somewhere in the code
if(time < Date.now()) permission.past() // -> 'дозволено'
if(time == Date.now()) permission.present() // -> 'дозволяти'
if(time > Date.now()) permission.future() // -> 'буде дозволено'
And, of course, define a plural forms
const item = format({
times: {
singular: 'предмет',
multiple: 'предмети',
infinite: 'предметів',
threshold: 4 // you can also set a threshold for multiple form
}
})
// somewhere in the code
item.infinite() // -> 'предметів'
item.plural(3) // -> 'предмети'
item.plural(1) // -> 'предмет'
License
0.0.1
2 years ago