feat: add pluralization rules for Russian (#2344)
Reviewed-on: https://kolaente.dev/vikunja/vikunja/pulls/2344 Reviewed-by: konrad <k@knt.li> Co-authored-by: andreymal <andriyano-31@mail.ru> Co-committed-by: andreymal <andriyano-31@mail.ru>
This commit is contained in:
parent
81bdad4beb
commit
73780e4b50
@ -1,4 +1,5 @@
|
|||||||
import {createI18n} from 'vue-i18n'
|
import {createI18n} from 'vue-i18n'
|
||||||
|
import type {PluralizationRule} from 'vue-i18n'
|
||||||
import langEN from './lang/en.json'
|
import langEN from './lang/en.json'
|
||||||
|
|
||||||
export const SUPPORTED_LOCALES = {
|
export const SUPPORTED_LOCALES = {
|
||||||
@ -36,6 +37,24 @@ export type ISOLanguage = string
|
|||||||
export const i18n = createI18n({
|
export const i18n = createI18n({
|
||||||
fallbackLocale: DEFAULT_LANGUAGE,
|
fallbackLocale: DEFAULT_LANGUAGE,
|
||||||
legacy: false,
|
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: {
|
messages: {
|
||||||
[DEFAULT_LANGUAGE]: langEN,
|
[DEFAULT_LANGUAGE]: langEN,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
Loading…
x
Reference in New Issue
Block a user