Skip to content

Commit

Permalink
[l10n] Improve Russian (ru-RU) locale (mui#11210)
Browse files Browse the repository at this point in the history
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
  • Loading branch information
2 people authored and DungTiger committed Jul 23, 2024
1 parent bb0f425 commit 86f1a8d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 45 deletions.
20 changes: 10 additions & 10 deletions packages/x-data-grid/src/locales/beBY.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -45,8 +45,8 @@ const beBYGrid: Partial<GridLocaleText> = {
toolbarFiltersTooltipActive: (count) =>
getPluralForm(count, {
one: 'актыўны фільтр',
twoToFour: 'актыўных фільтра',
other: 'актыўных фільтраў',
few: 'актыўных фільтра',
many: 'актыўных фільтраў',
}),

// Quick filter toolbar field
Expand Down Expand Up @@ -140,8 +140,8 @@ const beBYGrid: Partial<GridLocaleText> = {
columnHeaderFiltersTooltipActive: (count) =>
getPluralForm(count, {
one: 'актыўны фільтр',
twoToFour: 'актыўных фільтра',
other: 'актыўных фільтраў',
few: 'актыўных фільтра',
many: 'актыўных фільтраў',
}),
columnHeaderFiltersLabel: 'Паказаць фільтры',
columnHeaderSortIconLabel: 'Сартыраваць',
Expand All @@ -150,8 +150,8 @@ const beBYGrid: Partial<GridLocaleText> = {
footerRowSelected: (count) =>
getPluralForm(count, {
one: 'абраны радок',
twoToFour: 'абраных радка',
other: 'абраных радкоў',
few: 'абраных радка',
many: 'абраных радкоў',
}),

// Total row amount footer text
Expand Down
68 changes: 38 additions & 30 deletions packages/x-data-grid/src/locales/ruRU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<GridLocaleText> = {
// Root
noRowsLabel: 'Нет строк',
Expand All @@ -23,16 +43,12 @@ const ruRUGrid: Partial<GridLocaleText> = {
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: 'Поиск…',
Expand Down Expand Up @@ -122,30 +138,22 @@ const ruRUGrid: Partial<GridLocaleText> = {
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: 'Всего строк:',
Expand Down
11 changes: 6 additions & 5 deletions packages/x-data-grid/src/locales/ukUA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<GridLocaleText> = {
// Root
Expand Down

0 comments on commit 86f1a8d

Please sign in to comment.