diff --git a/docs/data/material/migration/upgrade-to-v9/upgrade-to-v9.md b/docs/data/material/migration/upgrade-to-v9/upgrade-to-v9.md index ff682210c48a3a..6d62ea197d7099 100644 --- a/docs/data/material/migration/upgrade-to-v9/upgrade-to-v9.md +++ b/docs/data/material/migration/upgrade-to-v9/upgrade-to-v9.md @@ -118,6 +118,46 @@ This also fixes an issue where props like `color` were consumed by the Grid inst ``` +### TablePagination numbers are formatted by default + +Pagination numbers in `TablePagination` are now formatted using `Intl.NumberFormat` according to the locale. +For example, `103177` is displayed as `103,177` in `en-US` or `103.177` in `de-DE`. + +To opt out of number formatting, provide a custom `labelDisplayedRows` function: + +```jsx + + `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}` + } +/> +``` + +Or when using a locale: + +```jsx +import { enUS } from '@mui/material/locale'; + +const theme = createTheme( + { + palette: { + primary: { main: '#1976d2' }, + }, + }, + enUS, + { + components: { + MuiTablePagination: { + defaultProps: { + labelDisplayedRows: ({ from, to, count }) => + `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`, + }, + }, + }, + }, +); +``` + ### Theme `MuiTouchRipple` has been removed from the theme `components` types (`ComponentsProps`, `ComponentsOverrides`, and `ComponentsVariants`). diff --git a/docs/pages/material-ui/api/table-pagination.json b/docs/pages/material-ui/api/table-pagination.json index dacabc881904e1..34291b781c5c42 100644 --- a/docs/pages/material-ui/api/table-pagination.json +++ b/docs/pages/material-ui/api/table-pagination.json @@ -27,7 +27,7 @@ }, "labelDisplayedRows": { "type": { "name": "func" }, - "default": "function defaultLabelDisplayedRows({ from, to, count }) {\n return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`;\n}" + "default": "function defaultLabelDisplayedRows({ from, to, count }) {\n return `${formatNumber(from)}–${formatNumber(to)} of ${count !== -1 ? formatNumber(count) : `more than ${formatNumber(to)}`}`;\n}" }, "labelRowsPerPage": { "type": { "name": "node" }, "default": "'Rows per page:'" }, "nextIconButtonProps": { diff --git a/packages/mui-material/src/TablePagination/TablePagination.d.ts b/packages/mui-material/src/TablePagination/TablePagination.d.ts index 6c9543577c1d11..e418cfb5aee7ac 100644 --- a/packages/mui-material/src/TablePagination/TablePagination.d.ts +++ b/packages/mui-material/src/TablePagination/TablePagination.d.ts @@ -200,7 +200,7 @@ export interface TablePaginationOwnProps extends TablePaginationBaseProps { * * For localization purposes, you can use the provided [translations](https://mui.com/material-ui/guides/localization/). * @default function defaultLabelDisplayedRows({ from, to, count }) { - * return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`; + * return `${formatNumber(from)}–${formatNumber(to)} of ${count !== -1 ? formatNumber(count) : `more than ${formatNumber(to)}`}`; * } */ labelDisplayedRows?: ((paginationInfo: LabelDisplayedRowsArgs) => React.ReactNode) | undefined; diff --git a/packages/mui-material/src/TablePagination/TablePagination.js b/packages/mui-material/src/TablePagination/TablePagination.js index 1bd8ef76c862a1..be93ed8183f017 100644 --- a/packages/mui-material/src/TablePagination/TablePagination.js +++ b/packages/mui-material/src/TablePagination/TablePagination.js @@ -17,6 +17,9 @@ import TablePaginationActions from '../TablePaginationActions'; import useId from '../utils/useId'; import tablePaginationClasses, { getTablePaginationUtilityClass } from './tablePaginationClasses'; import useSlot from '../utils/useSlot'; +import buildFormatNumber from '../locale/utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('en-US'); const TablePaginationRoot = styled(TableCell, { name: 'MuiTablePagination', @@ -114,7 +117,7 @@ const TablePaginationDisplayedRows = styled('p', { ); function defaultLabelDisplayedRows({ from, to, count }) { - return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`; + return `${formatNumber(from)}–${formatNumber(to)} of ${count !== -1 ? formatNumber(count) : `more than ${formatNumber(to)}`}`; } function defaultGetAriaLabel(type) { @@ -380,7 +383,7 @@ TablePagination.propTypes /* remove-proptypes */ = { * * For localization purposes, you can use the provided [translations](https://mui.com/material-ui/guides/localization/). * @default function defaultLabelDisplayedRows({ from, to, count }) { - * return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`; + * return `${formatNumber(from)}–${formatNumber(to)} of ${count !== -1 ? formatNumber(count) : `more than ${formatNumber(to)}`}`; * } */ labelDisplayedRows: PropTypes.func, diff --git a/packages/mui-material/src/locale/amET.ts b/packages/mui-material/src/locale/amET.ts index 3d40a1dead8bc6..bf95d817ac0dd5 100644 --- a/packages/mui-material/src/locale/amET.ts +++ b/packages/mui-material/src/locale/amET.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('am-ET'); export const amET: Localization = { components: { @@ -24,7 +27,7 @@ export const amET: Localization = { }, labelRowsPerPage: 'ረድፎች በአንድ ገጽ:', labelDisplayedRows: ({ from, to, count }) => - `${from}-${to} ከ ${count !== -1 ? count : `${to} በላይ`}`, + `${formatNumber(from)}-${formatNumber(to)} ከ ${count !== -1 ? formatNumber(count) : `${formatNumber(to)} በላይ`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/arEG.ts b/packages/mui-material/src/locale/arEG.ts index 942f33ed73d1c6..a1316ccdef37c3 100644 --- a/packages/mui-material/src/locale/arEG.ts +++ b/packages/mui-material/src/locale/arEG.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('ar-EG'); export const arEG: Localization = { components: { @@ -24,7 +27,7 @@ export const arEG: Localization = { }, labelRowsPerPage: 'عدد الصفوف في الصفحة:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} من ${count !== -1 ? count : ` أكثر من${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} من ${count !== -1 ? formatNumber(count) : ` أكثر من${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/arSA.ts b/packages/mui-material/src/locale/arSA.ts index 06d9cb3e9d134c..0f8efa9674b08d 100644 --- a/packages/mui-material/src/locale/arSA.ts +++ b/packages/mui-material/src/locale/arSA.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('ar-SA'); export const arSA: Localization = { components: { @@ -24,7 +27,7 @@ export const arSA: Localization = { }, labelRowsPerPage: 'عدد الصفوف في الصفحة:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} من ${count !== -1 ? count : ` أكثر من${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} من ${count !== -1 ? formatNumber(count) : ` أكثر من${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/arSD.ts b/packages/mui-material/src/locale/arSD.ts index 45649b74356fe9..391758df36297f 100644 --- a/packages/mui-material/src/locale/arSD.ts +++ b/packages/mui-material/src/locale/arSD.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('ar-SD'); export const arSD: Localization = { components: { @@ -24,7 +27,7 @@ export const arSD: Localization = { }, labelRowsPerPage: 'عدد الصفوف في الصفحة:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} من ${count !== -1 ? count : ` أكثر من${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} من ${count !== -1 ? formatNumber(count) : ` أكثر من${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/beBY.ts b/packages/mui-material/src/locale/beBY.ts index a94ba59f68e9d9..97b9ccf852ebb4 100644 --- a/packages/mui-material/src/locale/beBY.ts +++ b/packages/mui-material/src/locale/beBY.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('be-BY'); export const beBY: Localization = { components: { @@ -24,7 +27,7 @@ export const beBY: Localization = { }, labelRowsPerPage: 'Радкоў на старонцы:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} з ${count !== -1 ? count : `больш чым ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} з ${count !== -1 ? formatNumber(count) : `больш чым ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/bnBD.ts b/packages/mui-material/src/locale/bnBD.ts index 1347ae56f62c2e..d6f4955a6509eb 100644 --- a/packages/mui-material/src/locale/bnBD.ts +++ b/packages/mui-material/src/locale/bnBD.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('bn-BD'); export const bnBD: Localization = { components: { @@ -24,7 +27,7 @@ export const bnBD: Localization = { }, labelRowsPerPage: 'প্রতি পৃষ্ঠায় সারি:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} / ${count !== -1 ? count : `${to} থেকে বেশি`}`, + `${formatNumber(from)}–${formatNumber(to)} / ${count !== -1 ? formatNumber(count) : `${formatNumber(to)} থেকে বেশি`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/caES.ts b/packages/mui-material/src/locale/caES.ts index 9d4faf898964a4..13a9a5a94a7ca8 100644 --- a/packages/mui-material/src/locale/caES.ts +++ b/packages/mui-material/src/locale/caES.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('ca-ES'); export const caES: Localization = { components: { @@ -24,7 +27,7 @@ export const caES: Localization = { }, labelRowsPerPage: 'Files per pàgina:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} de ${count !== -1 ? count : `més de ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} de ${count !== -1 ? formatNumber(count) : `més de ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/csCZ.ts b/packages/mui-material/src/locale/csCZ.ts index e4215276d02cb6..b827e901de0b32 100644 --- a/packages/mui-material/src/locale/csCZ.ts +++ b/packages/mui-material/src/locale/csCZ.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('cs-CZ'); export const csCZ: Localization = { components: { @@ -24,7 +27,7 @@ export const csCZ: Localization = { }, labelRowsPerPage: 'Řádků na stránce:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} z ${count !== -1 ? count : `více než ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} z ${count !== -1 ? formatNumber(count) : `více než ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/daDK.ts b/packages/mui-material/src/locale/daDK.ts index 432097540e5bfd..2266610baced7f 100644 --- a/packages/mui-material/src/locale/daDK.ts +++ b/packages/mui-material/src/locale/daDK.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('da-DK'); export const daDK: Localization = { components: { @@ -24,7 +27,7 @@ export const daDK: Localization = { }, labelRowsPerPage: 'Rækker pr side:', labelDisplayedRows: ({ from, to, count }) => - `${from}-${to} af ${count !== -1 ? count : `mere end ${to}`}`, + `${formatNumber(from)}-${formatNumber(to)} af ${count !== -1 ? formatNumber(count) : `mere end ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/deDE.ts b/packages/mui-material/src/locale/deDE.ts index bb25a6f58076e3..25aa14f65376ea 100644 --- a/packages/mui-material/src/locale/deDE.ts +++ b/packages/mui-material/src/locale/deDE.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('de-DE'); export const deDE: Localization = { components: { @@ -24,7 +27,7 @@ export const deDE: Localization = { }, labelRowsPerPage: 'Zeilen pro Seite:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} von ${count !== -1 ? count : `mehr als ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} von ${count !== -1 ? formatNumber(count) : `mehr als ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/elGR.ts b/packages/mui-material/src/locale/elGR.ts index 7a5ac9e186e394..281f34962e62e9 100644 --- a/packages/mui-material/src/locale/elGR.ts +++ b/packages/mui-material/src/locale/elGR.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('el-GR'); export const elGR: Localization = { components: { @@ -25,7 +28,7 @@ export const elGR: Localization = { }, labelRowsPerPage: 'Γραμμές ανα σελίδα:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} από ${count !== -1 ? count : `πάνω από ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} από ${count !== -1 ? formatNumber(count) : `πάνω από ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/esES.ts b/packages/mui-material/src/locale/esES.ts index 31b80953a027bc..e1efccb249c7a0 100644 --- a/packages/mui-material/src/locale/esES.ts +++ b/packages/mui-material/src/locale/esES.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('es-ES'); export const esES: Localization = { components: { @@ -24,7 +27,7 @@ export const esES: Localization = { }, labelRowsPerPage: 'Filas por página:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} de ${count !== -1 ? count : `más de ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} de ${count !== -1 ? formatNumber(count) : `más de ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/etEE.ts b/packages/mui-material/src/locale/etEE.ts index 0924693387e873..bcb071a8d0dfc6 100644 --- a/packages/mui-material/src/locale/etEE.ts +++ b/packages/mui-material/src/locale/etEE.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('et-EE'); export const etEE: Localization = { components: { @@ -24,7 +27,7 @@ export const etEE: Localization = { }, labelRowsPerPage: 'Ridu leheküljel:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} / ${count !== -1 ? count : `rohkem kui ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} / ${count !== -1 ? formatNumber(count) : `rohkem kui ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/faIR.ts b/packages/mui-material/src/locale/faIR.ts index b435ff5345b879..9990ebd3d1314c 100644 --- a/packages/mui-material/src/locale/faIR.ts +++ b/packages/mui-material/src/locale/faIR.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('fa-IR'); export const faIR: Localization = { components: { @@ -29,7 +32,7 @@ export const faIR: Localization = { }, labelRowsPerPage: 'تعداد سطرهای هر صفحه:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} از ${count !== -1 ? count : `بیشتر از ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} از ${count !== -1 ? formatNumber(count) : `بیشتر از ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/fiFI.ts b/packages/mui-material/src/locale/fiFI.ts index f356bc04742229..36430b467ac484 100644 --- a/packages/mui-material/src/locale/fiFI.ts +++ b/packages/mui-material/src/locale/fiFI.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('fi-FI'); export const fiFI: Localization = { components: { @@ -24,7 +27,7 @@ export const fiFI: Localization = { }, labelRowsPerPage: 'Rivejä per sivu:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} / ${count !== -1 ? count : `enemmän kuin ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} / ${count !== -1 ? formatNumber(count) : `enemmän kuin ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/frFR.ts b/packages/mui-material/src/locale/frFR.ts index d13bfb700ac12f..7b2071be18c8f7 100644 --- a/packages/mui-material/src/locale/frFR.ts +++ b/packages/mui-material/src/locale/frFR.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('fr-FR'); export const frFR: Localization = { components: { @@ -24,7 +27,7 @@ export const frFR: Localization = { }, labelRowsPerPage: 'Lignes par page :', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} sur ${count !== -1 ? count : `plus que ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} sur ${count !== -1 ? formatNumber(count) : `plus que ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/heIL.ts b/packages/mui-material/src/locale/heIL.ts index 78d28b45686d69..a3e7821423a6ba 100644 --- a/packages/mui-material/src/locale/heIL.ts +++ b/packages/mui-material/src/locale/heIL.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('he-IL'); export const heIL: Localization = { components: { @@ -24,7 +27,7 @@ export const heIL: Localization = { }, labelRowsPerPage: 'שורות בעמוד:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} מתוך ${count !== -1 ? count : `יותר מ ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} מתוך ${count !== -1 ? formatNumber(count) : `יותר מ ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/hiIN.ts b/packages/mui-material/src/locale/hiIN.ts index 6cafe51b407c23..4271256c8e8c1d 100644 --- a/packages/mui-material/src/locale/hiIN.ts +++ b/packages/mui-material/src/locale/hiIN.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('hi-IN'); export const hiIN: Localization = { components: { @@ -24,7 +27,7 @@ export const hiIN: Localization = { }, labelRowsPerPage: 'पंक्तियाँ प्रति पृष्ठ:', labelDisplayedRows: ({ from, to, count }) => - `${from}-${to === -1 ? count : to} कुल ${count} में`, + `${formatNumber(from)}-${to === -1 ? formatNumber(count) : formatNumber(to)} कुल ${formatNumber(count)} में`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/hrHR.ts b/packages/mui-material/src/locale/hrHR.ts index ee6d6bb8c6590d..05355d06ab23db 100644 --- a/packages/mui-material/src/locale/hrHR.ts +++ b/packages/mui-material/src/locale/hrHR.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('hr-HR'); // Croatian - Hrvatski export const hrHR: Localization = { @@ -25,7 +28,7 @@ export const hrHR: Localization = { }, labelRowsPerPage: 'Redova po stranici:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} od ${count !== -1 ? count : `više nego ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} od ${count !== -1 ? formatNumber(count) : `više nego ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/isIS.ts b/packages/mui-material/src/locale/isIS.ts index 682c7e35247ecf..fd873fd3563b18 100644 --- a/packages/mui-material/src/locale/isIS.ts +++ b/packages/mui-material/src/locale/isIS.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('is-IS'); export const isIS: Localization = { components: { @@ -24,7 +27,7 @@ export const isIS: Localization = { }, labelRowsPerPage: 'Raðir á síðu:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} af ${count !== -1 ? count : `fleiri en ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} af ${count !== -1 ? formatNumber(count) : `fleiri en ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/itIT.ts b/packages/mui-material/src/locale/itIT.ts index 45f825a2c687c8..94e5aec46ec1fd 100644 --- a/packages/mui-material/src/locale/itIT.ts +++ b/packages/mui-material/src/locale/itIT.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('it-IT'); export const itIT: Localization = { components: { @@ -24,7 +27,7 @@ export const itIT: Localization = { }, labelRowsPerPage: 'Righe per pagina:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} di ${count !== -1 ? count : `più di ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} di ${count !== -1 ? formatNumber(count) : `più di ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/jaJP.ts b/packages/mui-material/src/locale/jaJP.ts index 378be7170b458f..2fa6d55653b73f 100644 --- a/packages/mui-material/src/locale/jaJP.ts +++ b/packages/mui-material/src/locale/jaJP.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('ja-JP'); export const jaJP: Localization = { components: { @@ -24,7 +27,7 @@ export const jaJP: Localization = { }, labelRowsPerPage: 'ページあたりの行数:', labelDisplayedRows: ({ from, to, count }) => - `${from}~${to} / ${count !== -1 ? count : `${to}以上`}`, + `${formatNumber(from)}~${formatNumber(to)} / ${count !== -1 ? formatNumber(count) : `${formatNumber(to)}以上`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/khKH.ts b/packages/mui-material/src/locale/khKH.ts index 83c9f3673721ce..e2045e5aab14a0 100644 --- a/packages/mui-material/src/locale/khKH.ts +++ b/packages/mui-material/src/locale/khKH.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('kh-KH'); export const khKH: Localization = { components: { @@ -24,7 +27,7 @@ export const khKH: Localization = { }, labelRowsPerPage: 'ចំនួនជួរដេកក្នុងមួយទំព័រ:', labelDisplayedRows: ({ from, to, count }) => - `${from} - ${to} នៃ ${count !== -1 ? count : `ច្រើនជាង ${to}`}`, + `${formatNumber(from)} - ${formatNumber(to)} នៃ ${count !== -1 ? formatNumber(count) : `ច្រើនជាង ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/kkKZ.ts b/packages/mui-material/src/locale/kkKZ.ts index 30a5bb1cd64e70..2bfc5bec03e04f 100644 --- a/packages/mui-material/src/locale/kkKZ.ts +++ b/packages/mui-material/src/locale/kkKZ.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('kk-KZ'); export const kkKZ: Localization = { components: { @@ -24,7 +27,7 @@ export const kkKZ: Localization = { }, labelRowsPerPage: 'Беттегі қатарлар:', labelDisplayedRows: ({ from, to, count }) => - `${count !== -1 ? count : `+${to}`} қатардың ішінен ${from}–${to}`, + `${count !== -1 ? formatNumber(count) : `+${formatNumber(to)}`} қатардың ішінен ${formatNumber(from)}–${formatNumber(to)}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/koKR.ts b/packages/mui-material/src/locale/koKR.ts index f01485c39d487b..0187d89c7261b9 100644 --- a/packages/mui-material/src/locale/koKR.ts +++ b/packages/mui-material/src/locale/koKR.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('ko-KR'); export const koKR: Localization = { components: { @@ -24,7 +27,7 @@ export const koKR: Localization = { }, labelRowsPerPage: '페이지 당 행:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} / ${count !== -1 ? count : `${to}개 이상`}`, + `${formatNumber(from)}–${formatNumber(to)} / ${count !== -1 ? formatNumber(count) : `${formatNumber(to)}개 이상`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/kuCKB.ts b/packages/mui-material/src/locale/kuCKB.ts index d8d38a3c9037f0..9184f5230379e1 100644 --- a/packages/mui-material/src/locale/kuCKB.ts +++ b/packages/mui-material/src/locale/kuCKB.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('ku-CKB'); export const kuCKB: Localization = { components: { @@ -24,7 +27,7 @@ export const kuCKB: Localization = { }, labelRowsPerPage: 'ژمارەی ڕیزەکان لە هەر پەڕەیەک:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} لە ${count !== -1 ? count : ` زیاترە لە${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} لە ${count !== -1 ? formatNumber(count) : ` زیاترە لە${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/kuLatn.ts b/packages/mui-material/src/locale/kuLatn.ts index cf690ea39dc816..fcb05577d4da91 100644 --- a/packages/mui-material/src/locale/kuLatn.ts +++ b/packages/mui-material/src/locale/kuLatn.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('ku-Latn'); export const kuLatn: Localization = { components: { @@ -24,7 +27,7 @@ export const kuLatn: Localization = { }, labelRowsPerPage: 'Rêz li ser rûpelê:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} of ${count !== -1 ? count : `zêdetir ji ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} of ${count !== -1 ? formatNumber(count) : `zêdetir ji ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/mkMK.ts b/packages/mui-material/src/locale/mkMK.ts index e018cd1ee4d5af..83926e9b559f8a 100644 --- a/packages/mui-material/src/locale/mkMK.ts +++ b/packages/mui-material/src/locale/mkMK.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('mk-MK'); // Macedonian - Македонски export const mkMK: Localization = { @@ -25,7 +28,7 @@ export const mkMK: Localization = { }, labelRowsPerPage: 'Редови по страница:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} од ${count !== -1 ? count : `повеќе од ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} од ${count !== -1 ? formatNumber(count) : `повеќе од ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/msMS.ts b/packages/mui-material/src/locale/msMS.ts index b061237204a1c1..353c12f1a68a3a 100644 --- a/packages/mui-material/src/locale/msMS.ts +++ b/packages/mui-material/src/locale/msMS.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('ms-MS'); // Malay-Melayu export const msMS: Localization = { @@ -25,7 +28,7 @@ export const msMS: Localization = { }, labelRowsPerPage: 'Baris setiap halaman:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} daripada ${count !== -1 ? count : `lebih daripada ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} daripada ${count !== -1 ? formatNumber(count) : `lebih daripada ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/myMY.ts b/packages/mui-material/src/locale/myMY.ts index b8c9a93874f838..b9f654c3986449 100644 --- a/packages/mui-material/src/locale/myMY.ts +++ b/packages/mui-material/src/locale/myMY.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('my-MY'); // Myanmar - မြန်မာ export const myMY: Localization = { @@ -25,7 +28,7 @@ export const myMY: Localization = { }, labelRowsPerPage: 'စာမျက်နှာအလိုက် အတန်းများ:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} ၏ ${count !== -1 ? count : `ထက်ပိုပြီး ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} ၏ ${count !== -1 ? formatNumber(count) : `ထက်ပိုပြီး ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/nbNO.ts b/packages/mui-material/src/locale/nbNO.ts index d84397cb45861d..ed2c505d544b5a 100644 --- a/packages/mui-material/src/locale/nbNO.ts +++ b/packages/mui-material/src/locale/nbNO.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('nb-NO'); export const nbNO: Localization = { components: { @@ -24,7 +27,7 @@ export const nbNO: Localization = { }, labelRowsPerPage: 'Rader per side:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} av ${count !== -1 ? count : `mer enn ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} av ${count !== -1 ? formatNumber(count) : `mer enn ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/neNP.ts b/packages/mui-material/src/locale/neNP.ts index 691830e1f5e650..541b3db3b411a8 100644 --- a/packages/mui-material/src/locale/neNP.ts +++ b/packages/mui-material/src/locale/neNP.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('ne-NP'); // Nepali-नेपाली export const neNP: Localization = { @@ -25,7 +28,7 @@ export const neNP: Localization = { }, labelRowsPerPage: 'प्रति पृष्ठ पङ्क्तिहरू:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} को ${count !== -1 ? count : `धेरै ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} को ${count !== -1 ? formatNumber(count) : `धेरै ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/nlNL.ts b/packages/mui-material/src/locale/nlNL.ts index ac852382153225..019189743967ee 100644 --- a/packages/mui-material/src/locale/nlNL.ts +++ b/packages/mui-material/src/locale/nlNL.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('nl-NL'); export const nlNL: Localization = { components: { @@ -24,7 +27,7 @@ export const nlNL: Localization = { }, labelRowsPerPage: 'Regels per pagina:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} van ${count !== -1 ? count : `meer dan ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} van ${count !== -1 ? formatNumber(count) : `meer dan ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/nnNO.ts b/packages/mui-material/src/locale/nnNO.ts index e713a8a32939f4..1a4096f482753d 100644 --- a/packages/mui-material/src/locale/nnNO.ts +++ b/packages/mui-material/src/locale/nnNO.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('nn-NO'); export const nnNO: Localization = { components: { @@ -24,7 +27,7 @@ export const nnNO: Localization = { }, labelRowsPerPage: 'Rader per side:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} av ${count !== -1 ? count : `fleire enn ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} av ${count !== -1 ? formatNumber(count) : `fleire enn ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/plPL.ts b/packages/mui-material/src/locale/plPL.ts index 8076970a15f319..3328bf62483b56 100644 --- a/packages/mui-material/src/locale/plPL.ts +++ b/packages/mui-material/src/locale/plPL.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('pl-PL'); export const plPL: Localization = { components: { @@ -24,7 +27,7 @@ export const plPL: Localization = { }, labelRowsPerPage: 'Wierszy na stronę:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} z ${count !== -1 ? count : `ponad ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} z ${count !== -1 ? formatNumber(count) : `ponad ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/psAF.ts b/packages/mui-material/src/locale/psAF.ts index 6915bd4f3f5ede..def7c9373731a5 100644 --- a/packages/mui-material/src/locale/psAF.ts +++ b/packages/mui-material/src/locale/psAF.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('ps-AF'); export const psAF: Localization = { components: { @@ -24,7 +27,7 @@ export const psAF: Localization = { }, labelRowsPerPage: 'په پاڼه کی د کرښو شمیر', labelDisplayedRows: ({ from, to, count }) => - `${count !== -1 ? count : `${to} زیات له`} ${to}- ${from} د`, + `${count !== -1 ? formatNumber(count) : `${formatNumber(to)} زیات له`} ${formatNumber(to)}- ${formatNumber(from)} د`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/ptBR.ts b/packages/mui-material/src/locale/ptBR.ts index 8ca195f2b7ab21..96cf508a7366b0 100644 --- a/packages/mui-material/src/locale/ptBR.ts +++ b/packages/mui-material/src/locale/ptBR.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('pt-BR'); export const ptBR: Localization = { components: { @@ -24,7 +27,7 @@ export const ptBR: Localization = { }, labelRowsPerPage: 'Linhas por página:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} de ${count !== -1 ? count : `mais de ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} de ${count !== -1 ? formatNumber(count) : `mais de ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/ptPT.ts b/packages/mui-material/src/locale/ptPT.ts index 1cd65b60b6a28d..27aefe4218af88 100644 --- a/packages/mui-material/src/locale/ptPT.ts +++ b/packages/mui-material/src/locale/ptPT.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('pt-PT'); export const ptPT: Localization = { components: { @@ -24,7 +27,7 @@ export const ptPT: Localization = { }, labelRowsPerPage: 'Linhas por página:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} de ${count !== -1 ? count : `mais de ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} de ${count !== -1 ? formatNumber(count) : `mais de ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/roRO.ts b/packages/mui-material/src/locale/roRO.ts index 01684b3e6dfcf5..e40f37e38be1ac 100644 --- a/packages/mui-material/src/locale/roRO.ts +++ b/packages/mui-material/src/locale/roRO.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('ro-RO'); export const roRO: Localization = { components: { @@ -24,7 +27,7 @@ export const roRO: Localization = { }, labelRowsPerPage: 'Rânduri pe pagină:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} din ${count !== -1 ? count : `mai mult de ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} din ${count !== -1 ? formatNumber(count) : `mai mult de ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/ruRU.ts b/packages/mui-material/src/locale/ruRU.ts index d94a0888116be4..5cb79b48c2278a 100644 --- a/packages/mui-material/src/locale/ruRU.ts +++ b/packages/mui-material/src/locale/ruRU.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('ru-RU'); export const ruRU: Localization = { components: { @@ -24,7 +27,7 @@ export const ruRU: Localization = { }, labelRowsPerPage: 'Строк на странице:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} из ${count !== -1 ? count : `более чем ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} из ${count !== -1 ? formatNumber(count) : `более чем ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/siLK.ts b/packages/mui-material/src/locale/siLK.ts index 51668c630a13ba..4eb8f9e9e65bb0 100644 --- a/packages/mui-material/src/locale/siLK.ts +++ b/packages/mui-material/src/locale/siLK.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('si-LK'); export const siLK: Localization = { components: { @@ -24,7 +27,7 @@ export const siLK: Localization = { }, labelRowsPerPage: 'පිටුවක පේළි:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} දක්වා ${count !== -1 ? count : `${to} ට වැඩි ප්‍රමාණයකින්`}`, + `${formatNumber(from)}–${formatNumber(to)} දක්වා ${count !== -1 ? formatNumber(count) : `${formatNumber(to)} ට වැඩි ප්‍රමාණයකින්`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/skSK.ts b/packages/mui-material/src/locale/skSK.ts index 77f7368cf01f3c..19955e3998bb5a 100644 --- a/packages/mui-material/src/locale/skSK.ts +++ b/packages/mui-material/src/locale/skSK.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('sk-SK'); export const skSK: Localization = { components: { @@ -24,7 +27,7 @@ export const skSK: Localization = { }, labelRowsPerPage: 'Riadkov na stránke:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} z ${count !== -1 ? count : `viac ako ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} z ${count !== -1 ? formatNumber(count) : `viac ako ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/srRS.ts b/packages/mui-material/src/locale/srRS.ts index b17f6d6d6eb666..ac30ab20d8949e 100644 --- a/packages/mui-material/src/locale/srRS.ts +++ b/packages/mui-material/src/locale/srRS.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('sr-RS'); // Serbian - Srpski export const srRS: Localization = { @@ -25,7 +28,7 @@ export const srRS: Localization = { }, labelRowsPerPage: 'Redova po stranici:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} od ${count !== -1 ? count : `više nego ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} od ${count !== -1 ? formatNumber(count) : `više nego ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/svSE.ts b/packages/mui-material/src/locale/svSE.ts index 8970ee31352b1e..872e8445b9e528 100644 --- a/packages/mui-material/src/locale/svSE.ts +++ b/packages/mui-material/src/locale/svSE.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('sv-SE'); export const svSE: Localization = { components: { @@ -24,7 +27,7 @@ export const svSE: Localization = { }, labelRowsPerPage: 'Rader per sida:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} av ${count !== -1 ? count : `fler än ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} av ${count !== -1 ? formatNumber(count) : `fler än ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/thTH.ts b/packages/mui-material/src/locale/thTH.ts index ec1d8e5321b97b..a5b8c9db9db1fb 100644 --- a/packages/mui-material/src/locale/thTH.ts +++ b/packages/mui-material/src/locale/thTH.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('th-TH'); export const thTH: Localization = { components: { @@ -24,7 +27,7 @@ export const thTH: Localization = { }, labelRowsPerPage: 'จำนวนแถวต่อหน้า:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} จาก ${count !== -1 ? count : `มากกว่า ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} จาก ${count !== -1 ? formatNumber(count) : `มากกว่า ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/tlTL.ts b/packages/mui-material/src/locale/tlTL.ts index 633053128d2d3d..44ec2d6a6a355c 100644 --- a/packages/mui-material/src/locale/tlTL.ts +++ b/packages/mui-material/src/locale/tlTL.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('tl-TL'); // Tagalog-Tagalog export const tlTL: Localization = { @@ -25,7 +28,7 @@ export const tlTL: Localization = { }, labelRowsPerPage: 'Mga hilera bawat pahina:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} ng ${count !== -1 ? count : `higit sa ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} ng ${count !== -1 ? formatNumber(count) : `higit sa ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/trTR.ts b/packages/mui-material/src/locale/trTR.ts index b6a6e0ffb43f63..1d2341dba01bf7 100644 --- a/packages/mui-material/src/locale/trTR.ts +++ b/packages/mui-material/src/locale/trTR.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('tr-TR'); export const trTR: Localization = { components: { @@ -24,7 +27,7 @@ export const trTR: Localization = { }, labelRowsPerPage: 'Sayfa başına satır:', labelDisplayedRows: ({ from, to, count }) => - `${from}-${to} / ${count !== -1 ? count : `${to}'den fazla`}`, + `${formatNumber(from)}-${formatNumber(to)} / ${count !== -1 ? formatNumber(count) : `${formatNumber(to)}'den fazla`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/ukUA.ts b/packages/mui-material/src/locale/ukUA.ts index 441694dfd2bea1..88a63f23d42510 100644 --- a/packages/mui-material/src/locale/ukUA.ts +++ b/packages/mui-material/src/locale/ukUA.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('uk-UA'); export const ukUA: Localization = { components: { @@ -24,7 +27,7 @@ export const ukUA: Localization = { }, labelRowsPerPage: 'Рядків на сторінці:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} з ${count !== -1 ? count : `понад ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} з ${count !== -1 ? formatNumber(count) : `понад ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/urPK.ts b/packages/mui-material/src/locale/urPK.ts index 4cbe9ab9081995..5419c16fd01755 100644 --- a/packages/mui-material/src/locale/urPK.ts +++ b/packages/mui-material/src/locale/urPK.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('ur-PK'); export const urPK: Localization = { components: { @@ -24,7 +27,7 @@ export const urPK: Localization = { }, labelRowsPerPage: 'ایک صفحے پر قطاریں:', labelDisplayedRows: ({ from, to, count }) => - `${count !== -1 ? `${count} میں سے` : `${to} سے ذیادہ میں سے`} ${from} سے ${to} قطاریں`, + `${count !== -1 ? `${formatNumber(count)} میں سے` : `${formatNumber(to)} سے ذیادہ میں سے`} ${formatNumber(from)} سے ${formatNumber(to)} قطاریں`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/utils/buildFormatNumber.test.ts b/packages/mui-material/src/locale/utils/buildFormatNumber.test.ts new file mode 100644 index 00000000000000..67e1b01f06d049 --- /dev/null +++ b/packages/mui-material/src/locale/utils/buildFormatNumber.test.ts @@ -0,0 +1,28 @@ +import { expect } from 'chai'; +import buildFormatNumber from './buildFormatNumber'; + +describe('buildFormatNumber', () => { + it('formats numbers using the given locale', () => { + const format = buildFormatNumber('en-US'); + expect(format(1000)).to.equal('1,000'); + expect(format(1234567)).to.equal('1,234,567'); + }); + + it('formats numbers with locale-specific separators', () => { + const format = buildFormatNumber('de-DE'); + expect(format(1000)).to.equal('1.000'); + }); + + it('returns string for non-finite values', () => { + const format = buildFormatNumber('en-US'); + expect(format(Infinity)).to.equal('Infinity'); + expect(format(-Infinity)).to.equal('-Infinity'); + expect(format(NaN)).to.equal('NaN'); + }); + + it('handles zero and negative numbers', () => { + const format = buildFormatNumber('en-US'); + expect(format(0)).to.equal('0'); + expect(format(-1000)).to.equal('-1,000'); + }); +}); diff --git a/packages/mui-material/src/locale/utils/buildFormatNumber.ts b/packages/mui-material/src/locale/utils/buildFormatNumber.ts new file mode 100644 index 00000000000000..8c75f108620886 --- /dev/null +++ b/packages/mui-material/src/locale/utils/buildFormatNumber.ts @@ -0,0 +1,18 @@ +const buildFormatNumber = (locale: string) => { + let formatter: Intl.NumberFormat | undefined; + if (typeof Intl !== 'undefined' && Intl.NumberFormat) { + try { + formatter = new Intl.NumberFormat(locale); + } catch { + // fallback to String() + } + } + return (value: number) => { + if (!Number.isFinite(value)) { + return String(value); + } + return formatter ? formatter.format(value) : String(value); + }; +}; + +export default buildFormatNumber; diff --git a/packages/mui-material/src/locale/viVN.ts b/packages/mui-material/src/locale/viVN.ts index 949f2827d41ac2..4a51be24309ff4 100644 --- a/packages/mui-material/src/locale/viVN.ts +++ b/packages/mui-material/src/locale/viVN.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('vi-VN'); export const viVN: Localization = { components: { @@ -24,7 +27,7 @@ export const viVN: Localization = { }, labelRowsPerPage: 'Số hàng mỗi trang:', labelDisplayedRows: ({ from, to, count }) => - `${from}–${to} trong ${count !== -1 ? count : `nhiều hơn ${to}`}`, + `${formatNumber(from)}–${formatNumber(to)} trong ${count !== -1 ? formatNumber(count) : `nhiều hơn ${formatNumber(to)}`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/zhCN.ts b/packages/mui-material/src/locale/zhCN.ts index 809862ec634640..f67adac0191c04 100644 --- a/packages/mui-material/src/locale/zhCN.ts +++ b/packages/mui-material/src/locale/zhCN.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('zh-CN'); export const zhCN: Localization = { components: { @@ -23,7 +26,7 @@ export const zhCN: Localization = { }, labelRowsPerPage: '每页行数:', labelDisplayedRows: ({ from, to, count }) => - `第 ${from} 条到第 ${to} 条,${count !== -1 ? `共 ${count} 条` : `至少 ${to} 条`}`, + `第 ${formatNumber(from)} 条到第 ${formatNumber(to)} 条,${count !== -1 ? `共 ${formatNumber(count)} 条` : `至少 ${formatNumber(to)} 条`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/zhHK.ts b/packages/mui-material/src/locale/zhHK.ts index ed13ec996368ee..1d493946fef952 100644 --- a/packages/mui-material/src/locale/zhHK.ts +++ b/packages/mui-material/src/locale/zhHK.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('zh-HK'); export const zhHK: Localization = { components: { @@ -23,7 +26,7 @@ export const zhHK: Localization = { }, labelRowsPerPage: '每頁行數:', labelDisplayedRows: ({ from, to, count }) => - `第 ${from} 項至第 ${to} 項,${count !== -1 ? `共 ${count} 項` : `超過 ${to} 項`}`, + `第 ${formatNumber(from)} 項至第 ${formatNumber(to)} 項,${count !== -1 ? `共 ${formatNumber(count)} 項` : `超過 ${formatNumber(to)} 項`}`, }, }, MuiRating: { diff --git a/packages/mui-material/src/locale/zhTW.ts b/packages/mui-material/src/locale/zhTW.ts index ecdc6b70a59082..88c93e5c1fd0b3 100644 --- a/packages/mui-material/src/locale/zhTW.ts +++ b/packages/mui-material/src/locale/zhTW.ts @@ -1,4 +1,7 @@ import type { Localization } from './utils/LocaleTextApi'; +import buildFormatNumber from './utils/buildFormatNumber'; + +const formatNumber = buildFormatNumber('zh-TW'); export const zhTW: Localization = { components: { @@ -23,7 +26,7 @@ export const zhTW: Localization = { }, labelRowsPerPage: '每頁數量:', labelDisplayedRows: ({ from, to, count }) => - `${from} ~ ${to} / ${count !== -1 ? count : `${to} 以上`}`, + `${formatNumber(from)} ~ ${formatNumber(to)} / ${count !== -1 ? formatNumber(count) : `${formatNumber(to)} 以上`}`, }, }, MuiRating: {