From 7b52000365e06e0634ad8f735897bc57df637629 Mon Sep 17 00:00:00 2001 From: dastan-akhmetov-scity <152173801+dastan-akhmetov-scity@users.noreply.github.com> Date: Mon, 10 Jun 2024 03:16:08 +0500 Subject: [PATCH] [l10n] Improve Russian (ru-RU) locale (#11210) Co-authored-by: Olivier Tassinari --- packages/x-data-grid/src/locales/beBY.ts | 20 +++---- packages/x-data-grid/src/locales/ruRU.ts | 68 +++++++++++++----------- packages/x-data-grid/src/locales/ukUA.ts | 11 ++-- 3 files changed, 54 insertions(+), 45 deletions(-) diff --git a/packages/x-data-grid/src/locales/beBY.ts b/packages/x-data-grid/src/locales/beBY.ts index d2aaaa7729c5b..b10dd30d81fd1 100644 --- a/packages/x-data-grid/src/locales/beBY.ts +++ b/packages/x-data-grid/src/locales/beBY.ts @@ -4,16 +4,16 @@ import { getGridLocalization, Localization } from '../utils/getGridLocalization' type PluralForm = { one: string; - twoToFour: string; - other: string; + few: string; + many: string; }; const getPluralForm = (count: number, options: PluralForm) => { - let pluralForm = options.other; + let pluralForm = options.many; const lastDigit = count % 10; if (lastDigit > 1 && lastDigit < 5 && (count < 10 || count > 20)) { - pluralForm = options.twoToFour; + pluralForm = options.few; } else if (lastDigit === 1 && count % 100 !== 11) { pluralForm = options.one; } @@ -45,8 +45,8 @@ const beBYGrid: Partial = { toolbarFiltersTooltipActive: (count) => getPluralForm(count, { one: 'актыўны фільтр', - twoToFour: 'актыўных фільтра', - other: 'актыўных фільтраў', + few: 'актыўных фільтра', + many: 'актыўных фільтраў', }), // Quick filter toolbar field @@ -140,8 +140,8 @@ const beBYGrid: Partial = { columnHeaderFiltersTooltipActive: (count) => getPluralForm(count, { one: 'актыўны фільтр', - twoToFour: 'актыўных фільтра', - other: 'актыўных фільтраў', + few: 'актыўных фільтра', + many: 'актыўных фільтраў', }), columnHeaderFiltersLabel: 'Паказаць фільтры', columnHeaderSortIconLabel: 'Сартыраваць', @@ -150,8 +150,8 @@ const beBYGrid: Partial = { footerRowSelected: (count) => getPluralForm(count, { one: 'абраны радок', - twoToFour: 'абраных радка', - other: 'абраных радкоў', + few: 'абраных радка', + many: 'абраных радкоў', }), // Total row amount footer text diff --git a/packages/x-data-grid/src/locales/ruRU.ts b/packages/x-data-grid/src/locales/ruRU.ts index f08cfba7b4da1..7312e34d60ba9 100644 --- a/packages/x-data-grid/src/locales/ruRU.ts +++ b/packages/x-data-grid/src/locales/ruRU.ts @@ -2,6 +2,26 @@ import { ruRU as ruRUCore } from '@mui/material/locale'; import { GridLocaleText } from '../models/api/gridLocaleTextApi'; import { getGridLocalization, Localization } from '../utils/getGridLocalization'; +type PluralForm = { + one: string; + few: string; + many: string; +}; + +function getPluralForm(count: number, options: PluralForm) { + const penultimateDigit = Math.floor(count / 10) % 10; + const lastDigit = count % 10; + + let pluralForm = options.many; + if (penultimateDigit !== 1 && lastDigit > 1 && lastDigit < 5) { + pluralForm = options.few; + } else if (penultimateDigit !== 1 && lastDigit === 1) { + pluralForm = options.one; + } + + return `${count} ${pluralForm}`; +} + const ruRUGrid: Partial = { // Root noRowsLabel: 'Нет строк', @@ -23,16 +43,12 @@ const ruRUGrid: Partial = { toolbarFiltersLabel: 'Показать фильтры', toolbarFiltersTooltipHide: 'Скрыть фильтры', toolbarFiltersTooltipShow: 'Показать фильтры', - toolbarFiltersTooltipActive: (count) => { - let pluralForm = 'активных фильтров'; - const lastDigit = count % 10; - if (lastDigit > 1 && lastDigit < 5) { - pluralForm = 'активных фильтра'; - } else if (lastDigit === 1) { - pluralForm = 'активный фильтр'; - } - return `${count} ${pluralForm}`; - }, + toolbarFiltersTooltipActive: (count) => + getPluralForm(count, { + one: 'активный фильтр', + few: 'активных фильтра', + many: 'активных фильтров', + }), // Quick filter toolbar field toolbarQuickFilterPlaceholder: 'Поиск…', @@ -122,30 +138,22 @@ const ruRUGrid: Partial = { columnMenuSortDesc: 'Сортировать по убыванию', // Column header text - columnHeaderFiltersTooltipActive: (count) => { - let pluralForm = 'активных фильтров'; - const lastDigit = count % 10; - if (lastDigit > 1 && lastDigit < 5) { - pluralForm = 'активных фильтра'; - } else if (lastDigit === 1) { - pluralForm = 'активный фильтр'; - } - return `${count} ${pluralForm}`; - }, + columnHeaderFiltersTooltipActive: (count) => + getPluralForm(count, { + one: 'активный фильтр', + few: 'активных фильтра', + many: 'активных фильтров', + }), columnHeaderFiltersLabel: 'Показать фильтры', columnHeaderSortIconLabel: 'Сортировать', // Rows selected footer text - footerRowSelected: (count) => { - let pluralForm = 'строк выбрано'; - const lastDigit = count % 10; - if (lastDigit > 1 && lastDigit < 5) { - pluralForm = 'строки выбраны'; - } else if (lastDigit === 1) { - pluralForm = 'строка выбрана'; - } - return `${count} ${pluralForm}`; - }, + footerRowSelected: (count) => + getPluralForm(count, { + one: 'строка выбрана', + few: 'строки выбраны', + many: 'строк выбрано', + }), // Total row amount footer text footerTotalRows: 'Всего строк:', diff --git a/packages/x-data-grid/src/locales/ukUA.ts b/packages/x-data-grid/src/locales/ukUA.ts index 22185c2c34e93..bfb45ead7c686 100644 --- a/packages/x-data-grid/src/locales/ukUA.ts +++ b/packages/x-data-grid/src/locales/ukUA.ts @@ -8,18 +8,19 @@ type PluralForm = { many: string; }; -const getPluralForm = (count: number, options: PluralForm) => { - let pluralForm = options.many; +function getPluralForm(count: number, options: PluralForm) { + const penultimateDigit = Math.floor(count / 10) % 10; const lastDigit = count % 10; - if (lastDigit > 1 && lastDigit < 5) { + let pluralForm = options.many; + if (penultimateDigit !== 1 && lastDigit > 1 && lastDigit < 5) { pluralForm = options.few; - } else if (lastDigit === 1) { + } else if (penultimateDigit !== 1 && lastDigit === 1) { pluralForm = options.one; } return `${count} ${pluralForm}`; -}; +} const ukUAGrid: Partial = { // Root