-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: some refactoring and new tests (#177)
* chore: removed old service * chore: added wallabyjs to container * feat: env in dev container * feat: vitest plugin with cool coverage ui * chore: some more tests, refactoring * fix: date tests
- Loading branch information
1 parent
7c8fd4f
commit 2f8aecb
Showing
7 changed files
with
53 additions
and
24 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
export function pluralizationRu(int: number, array: [string, string, string]): string { | ||
const i = Math.abs(int) | ||
const n = Math.abs(int) | ||
|
||
return array[ | ||
i % 100 > 4 && i % 100 < 20 | ||
? 2 | ||
: [2, 0, 1, 1, 1, 2][i % 10 < 5 ? i % 10 : 5] | ||
] | ||
let idx | ||
// @see http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html | ||
if (n % 10 === 1 && n % 100 !== 11) { | ||
idx = 0 // one | ||
} else if (n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20)) { | ||
idx = 1 // few | ||
} else { | ||
idx = 2 // many | ||
} | ||
|
||
return array[idx] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters