add declension of words
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
export const pluralize = (number: number, one: string, few: string, many: string) => {
|
||||
const n = Math.abs(number) % 100;
|
||||
const n1 = n % 10;
|
||||
|
||||
if (n > 10 && n < 20) return many; // 11-19
|
||||
if (n1 > 1 && n1 < 5) return few; // 2-4 (кроме 12-14)
|
||||
if (n1 === 1) return one; // 1 (кроме 11)
|
||||
|
||||
return many; // 0, 5-9, 10-20, 25-30 и т.д.
|
||||
};
|
||||
Reference in New Issue
Block a user