Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[l10n] Improve Russian (ru-RU) locale #11210

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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