From 73780e4b5007d3dfbd3b4f92d9cb1c38d603fe27 Mon Sep 17 00:00:00 2001 From: andreymal Date: Mon, 3 Jun 2024 08:51:11 +0000 Subject: [PATCH] feat: add pluralization rules for Russian (#2344) Reviewed-on: https://kolaente.dev/vikunja/vikunja/pulls/2344 Reviewed-by: konrad Co-authored-by: andreymal Co-committed-by: andreymal --- frontend/src/i18n/index.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/frontend/src/i18n/index.ts b/frontend/src/i18n/index.ts index 27cdd4c72..0f348f3a8 100644 --- a/frontend/src/i18n/index.ts +++ b/frontend/src/i18n/index.ts @@ -1,4 +1,5 @@ import {createI18n} from 'vue-i18n' +import type {PluralizationRule} from 'vue-i18n' import langEN from './lang/en.json' export const SUPPORTED_LOCALES = { @@ -36,6 +37,24 @@ export type ISOLanguage = string export const i18n = createI18n({ fallbackLocale: DEFAULT_LANGUAGE, legacy: false, + pluralRules: { + 'ru-RU': (choice: number, choicesLength: number, orgRule?: PluralizationRule) => { + if (choicesLength !== 3) { + return orgRule ? orgRule(choice, choicesLength) : 0 + } + const n = Math.abs(choice) % 100 + if (n > 10 && n < 20) { + return 2 + } + if (n % 10 === 1) { + return 0 + } + if (n % 10 >= 2 && n % 10 <= 4) { + return 1 + } + return 2 + }, + }, messages: { [DEFAULT_LANGUAGE]: langEN, // eslint-disable-next-line @typescript-eslint/no-explicit-any