diff --git a/components/calendar/generateCalendar.tsx b/components/calendar/generateCalendar.tsx index 1f0834398b..ae8fbe595e 100644 --- a/components/calendar/generateCalendar.tsx +++ b/components/calendar/generateCalendar.tsx @@ -10,7 +10,7 @@ import type { import useMergedState from 'rc-util/lib/hooks/useMergedState'; import * as React from 'react'; import { ConfigContext } from '../config-provider'; -import useLocale from '../locale/useLocale'; +import { useLocale } from '../locale'; import CalendarHeader from './Header'; import enUS from './locale/en_US'; diff --git a/components/date-picker/__tests__/other.test.tsx b/components/date-picker/__tests__/other.test.tsx index 7af93c50a3..e4c0edeff1 100644 --- a/components/date-picker/__tests__/other.test.tsx +++ b/components/date-picker/__tests__/other.test.tsx @@ -5,7 +5,6 @@ import React from 'react'; import DatePicker from '..'; import ConfigProvider from '../../config-provider'; import type { Locale } from '../../locale'; -import LocaleProvider from '../../locale'; import locale from '../../locale/zh_CN'; import jaJP from '../../locale/ja_JP'; import zhTW from '../locale/zh_TW'; @@ -31,9 +30,9 @@ describe('Picker format by locale', () => { function matchPicker(name: string, Picker: typeof MonthPicker | typeof WeekPicker, props?: any) { it(name, () => { const { container } = render( - + - , + , ); expect(container.firstChild).toMatchSnapshot(); }); diff --git a/components/date-picker/generatePicker/generateRangePicker.tsx b/components/date-picker/generatePicker/generateRangePicker.tsx index c60c550071..a6bd7e6fc5 100644 --- a/components/date-picker/generatePicker/generateRangePicker.tsx +++ b/components/date-picker/generatePicker/generateRangePicker.tsx @@ -13,7 +13,7 @@ import { ConfigContext } from '../../config-provider'; import DisabledContext from '../../config-provider/DisabledContext'; import SizeContext from '../../config-provider/SizeContext'; import { FormItemInputContext } from '../../form/context'; -import useLocale from '../../locale/useLocale'; +import { useLocale } from '../../locale'; import { useCompactItemContext } from '../../space/Compact'; import { getMergedStatus, getStatusClassNames } from '../../_util/statusUtils'; import warning from '../../_util/warning'; diff --git a/components/date-picker/generatePicker/generateSinglePicker.tsx b/components/date-picker/generatePicker/generateSinglePicker.tsx index b3a8ffb0d7..ae755cfa3c 100644 --- a/components/date-picker/generatePicker/generateSinglePicker.tsx +++ b/components/date-picker/generatePicker/generateSinglePicker.tsx @@ -13,7 +13,7 @@ import { ConfigContext } from '../../config-provider'; import DisabledContext from '../../config-provider/DisabledContext'; import SizeContext from '../../config-provider/SizeContext'; import { FormItemInputContext } from '../../form/context'; -import useLocale from '../../locale/useLocale'; +import { useLocale } from '../../locale'; import { useCompactItemContext } from '../../space/Compact'; import type { InputStatus } from '../../_util/statusUtils'; import { getMergedStatus, getStatusClassNames } from '../../_util/statusUtils'; diff --git a/components/empty/index.tsx b/components/empty/index.tsx index f2a5c1f32f..56e7628e76 100644 --- a/components/empty/index.tsx +++ b/components/empty/index.tsx @@ -1,7 +1,7 @@ import classNames from 'classnames'; import * as React from 'react'; import { ConfigContext } from '../config-provider'; -import useLocale from '../locale/useLocale'; +import { useLocale } from '../locale'; import DefaultEmptyImg from './empty'; import SimpleEmptyImg from './simple'; diff --git a/components/form/FormItemLabel.tsx b/components/form/FormItemLabel.tsx index 1ec42e1767..89f01ab0b8 100644 --- a/components/form/FormItemLabel.tsx +++ b/components/form/FormItemLabel.tsx @@ -4,7 +4,7 @@ import * as React from 'react'; import type { ColProps } from '../grid/col'; import Col from '../grid/col'; import defaultLocale from '../locale/en_US'; -import useLocale from '../locale/useLocale'; +import { useLocale } from '../locale'; import type { TooltipProps } from '../tooltip'; import Tooltip from '../tooltip'; import type { FormContextProps } from './context'; diff --git a/components/locale-provider/LocaleReceiver.ts b/components/locale-provider/LocaleReceiver.ts deleted file mode 100644 index fd15dc9552..0000000000 --- a/components/locale-provider/LocaleReceiver.ts +++ /dev/null @@ -1,6 +0,0 @@ -// locale-provider 文件夹的移除需要修改 @ant-design/tools 和 antd-img-crop -import useLocale from '../locale/useLocale'; - -export * from '../locale/useLocale'; - -export default useLocale; diff --git a/components/locale-provider/index.ts b/components/locale-provider/index.ts deleted file mode 100644 index 391dae433c..0000000000 --- a/components/locale-provider/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// locale-provider 文件夹的移除需要修改 @ant-design/tools 和 antd-img-crop -import locale from '../locale'; - -export * from '../locale'; - -export default locale; diff --git a/components/locale-provider/__tests__/__snapshots__/index.test.tsx.snap b/components/locale/__tests__/__snapshots__/index.test.tsx.snap similarity index 100% rename from components/locale-provider/__tests__/__snapshots__/index.test.tsx.snap rename to components/locale/__tests__/__snapshots__/index.test.tsx.snap diff --git a/components/locale-provider/__tests__/cached-context.test.tsx b/components/locale/__tests__/cached-context.test.tsx similarity index 91% rename from components/locale-provider/__tests__/cached-context.test.tsx rename to components/locale/__tests__/cached-context.test.tsx index b690de29bb..c9a9406e66 100644 --- a/components/locale-provider/__tests__/cached-context.test.tsx +++ b/components/locale/__tests__/cached-context.test.tsx @@ -1,7 +1,7 @@ import React, { memo, useContext } from 'react'; import { fireEvent, pureRender } from '../../../tests/utils'; -import LocaleProvider from '../../locale'; -import LocaleContext from '../../locale/context'; +import LocaleProvider from '..'; +import LocaleContext from '../context'; let innerCount = 0; let outerCount = 0; diff --git a/components/locale-provider/__tests__/config.test.tsx b/components/locale/__tests__/config.test.tsx similarity index 97% rename from components/locale-provider/__tests__/config.test.tsx rename to components/locale/__tests__/config.test.tsx index 70c5b8ad1e..886db210d8 100644 --- a/components/locale-provider/__tests__/config.test.tsx +++ b/components/locale/__tests__/config.test.tsx @@ -2,7 +2,7 @@ import React, { useEffect } from 'react'; import { Modal } from '../..'; import { waitFakeTimer, render, fireEvent } from '../../../tests/utils'; import ConfigProvider from '../../config-provider'; -import zhCN from '../../locale/zh_CN'; +import zhCN from '../zh_CN'; const Demo: React.FC<{ type: string }> = ({ type }) => { useEffect(() => { diff --git a/components/locale-provider/__tests__/index.test.tsx b/components/locale/__tests__/index.test.tsx similarity index 98% rename from components/locale-provider/__tests__/index.test.tsx rename to components/locale/__tests__/index.test.tsx index 5607adc4b5..b64d118f0d 100644 --- a/components/locale-provider/__tests__/index.test.tsx +++ b/components/locale/__tests__/index.test.tsx @@ -68,8 +68,8 @@ import preParsePostFormat from 'dayjs/plugin/preParsePostFormat'; import MockDate from 'mockdate'; import React from 'react'; import { render } from '../../../tests/utils'; -import type { Locale } from '../../locale'; -import LocaleProvider from '../../locale'; +import type { Locale } from '..'; +import LocaleProvider from '..'; import { Calendar, DatePicker, diff --git a/components/locale/index.tsx b/components/locale/index.tsx index 9e6cfe315c..34f75c9a26 100644 --- a/components/locale/index.tsx +++ b/components/locale/index.tsx @@ -14,6 +14,8 @@ import type { UploadLocale } from '../upload/interface'; import type { LocaleContextProps } from './context'; import LocaleContext from './context'; +export { default as useLocale } from './useLocale'; + export const ANT_MARK = 'internalMark'; export interface Locale { diff --git a/components/locale/my_MM.ts b/components/locale/my_MM.ts index a8ae3b1565..57f30dccc9 100644 --- a/components/locale/my_MM.ts +++ b/components/locale/my_MM.ts @@ -5,7 +5,6 @@ import DatePicker from '../date-picker/locale/my_MM'; import type { Locale } from '.'; import TimePicker from '../time-picker/locale/my_MM'; - const typeTemplate = '${label} သည် တရားဝင် ${type} မဟုတ်ပါ'; const localeValues: Locale = { diff --git a/components/modal/ConfirmDialog.tsx b/components/modal/ConfirmDialog.tsx index 54c0e9686a..84f36b22d2 100644 --- a/components/modal/ConfirmDialog.tsx +++ b/components/modal/ConfirmDialog.tsx @@ -5,7 +5,7 @@ import InfoCircleFilled from '@ant-design/icons/InfoCircleFilled'; import classNames from 'classnames'; import * as React from 'react'; import ConfigProvider from '../config-provider'; -import useLocale from '../locale/useLocale'; +import { useLocale } from '../locale'; import ActionButton from '../_util/ActionButton'; import { getTransitionName } from '../_util/motion'; import warning from '../_util/warning'; diff --git a/components/modal/PurePanel.tsx b/components/modal/PurePanel.tsx index 55a38831bf..fe8c085e5d 100644 --- a/components/modal/PurePanel.tsx +++ b/components/modal/PurePanel.tsx @@ -7,7 +7,7 @@ import * as React from 'react'; import Button from '../button'; import { convertLegacyProps } from '../button/button'; import { ConfigContext } from '../config-provider'; -import useLocale from '../locale/useLocale'; +import { useLocale } from '../locale'; import { ConfirmContent } from './ConfirmDialog'; import { getConfirmLocale } from './locale'; import type { ModalFuncProps, ModalProps } from './Modal'; diff --git a/components/pagination/Pagination.tsx b/components/pagination/Pagination.tsx index 4cf2724e84..611acc09db 100644 --- a/components/pagination/Pagination.tsx +++ b/components/pagination/Pagination.tsx @@ -9,7 +9,7 @@ import enUS from 'rc-pagination/lib/locale/en_US'; import * as React from 'react'; import { ConfigContext } from '../config-provider'; import useBreakpoint from '../grid/hooks/useBreakpoint'; -import useLocale from '../locale/useLocale'; +import { useLocale } from '../locale'; import { MiddleSelect, MiniSelect } from './Select'; import useStyle from './style'; diff --git a/components/popconfirm/PurePanel.tsx b/components/popconfirm/PurePanel.tsx index 8b006d65bd..52b21eaaf6 100644 --- a/components/popconfirm/PurePanel.tsx +++ b/components/popconfirm/PurePanel.tsx @@ -6,7 +6,7 @@ import Button from '../button'; import { convertLegacyProps } from '../button/button'; import { ConfigContext } from '../config-provider'; import defaultLocale from '../locale/en_US'; -import useLocale from '../locale/useLocale'; +import { useLocale } from '../locale'; import PopoverPurePanel from '../popover/PurePanel'; import ActionButton from '../_util/ActionButton'; import { getRenderPropValue } from '../_util/getRenderPropValue'; diff --git a/components/qrcode/index.tsx b/components/qrcode/index.tsx index 64f4e38b36..cc0e1051e9 100644 --- a/components/qrcode/index.tsx +++ b/components/qrcode/index.tsx @@ -6,7 +6,7 @@ import warning from '../_util/warning'; import Button from '../button'; import type { ConfigConsumerProps } from '../config-provider'; import { ConfigContext } from '../config-provider'; -import useLocale from '../locale/useLocale'; +import { useLocale } from '../locale'; import Spin from '../spin'; import theme from '../theme'; import type { QRCodeProps, QRPropsCanvas } from './interface'; diff --git a/components/time-picker/locale/my_MM.ts b/components/time-picker/locale/my_MM.ts index 581d4035b4..828136654b 100644 --- a/components/time-picker/locale/my_MM.ts +++ b/components/time-picker/locale/my_MM.ts @@ -5,4 +5,4 @@ const locale: TimePickerLocale = { rangePlaceholder: ['စတင်ချိန်', 'ကုန်ဆုံးချိန်'], }; -export default locale; \ No newline at end of file +export default locale; diff --git a/components/tour/panelRender.tsx b/components/tour/panelRender.tsx index 0176a58c3b..94e31028cf 100644 --- a/components/tour/panelRender.tsx +++ b/components/tour/panelRender.tsx @@ -5,7 +5,7 @@ import React from 'react'; import type { ButtonProps } from '../button'; import Button from '../button'; import defaultLocale from '../locale/en_US'; -import useLocale from '../locale/useLocale'; +import { useLocale } from '../locale'; import type { TourStepProps } from './interface'; function isValidNode(node: ReactNode): boolean { diff --git a/components/transfer/ListItem.tsx b/components/transfer/ListItem.tsx index d031e76e9e..0bca1a22ff 100644 --- a/components/transfer/ListItem.tsx +++ b/components/transfer/ListItem.tsx @@ -4,7 +4,7 @@ import * as React from 'react'; import type { KeyWiseTransferItem } from '.'; import Checkbox from '../checkbox'; import defaultLocale from '../locale/en_US'; -import useLocale from '../locale/useLocale'; +import { useLocale } from '../locale'; import TransButton from '../_util/transButton'; type ListItemProps = { diff --git a/components/transfer/index.tsx b/components/transfer/index.tsx index 030a328a1d..32be292515 100644 --- a/components/transfer/index.tsx +++ b/components/transfer/index.tsx @@ -11,7 +11,7 @@ import DefaultRenderEmpty from '../config-provider/defaultRenderEmpty'; import type { FormItemStatusContextProps } from '../form/context'; import { FormItemInputContext } from '../form/context'; import defaultLocale from '../locale/en_US'; -import useLocale from '../locale/useLocale'; +import { useLocale } from '../locale'; import type { PaginationType } from './interface'; import type { TransferListProps } from './list'; import List from './list'; diff --git a/components/upload/Upload.tsx b/components/upload/Upload.tsx index d3aeb256b1..0e5e0b52ba 100644 --- a/components/upload/Upload.tsx +++ b/components/upload/Upload.tsx @@ -7,7 +7,7 @@ import { flushSync } from 'react-dom'; import { ConfigContext } from '../config-provider'; import DisabledContext from '../config-provider/DisabledContext'; import defaultLocale from '../locale/en_US'; -import useLocale from '../locale/useLocale'; +import { useLocale } from '../locale'; import warning from '../_util/warning'; import type { RcFile, ShowUploadListInterface, UploadChangeParam, UploadFile } from './interface'; import { UploadProps } from './interface'; diff --git a/docs/react/i18n.zh-CN.md b/docs/react/i18n.zh-CN.md index 942b67f792..5c04ef6527 100644 --- a/docs/react/i18n.zh-CN.md +++ b/docs/react/i18n.zh-CN.md @@ -94,7 +94,7 @@ return ( | 简体中文 | zh_CN | | 繁体中文(中国香港) | zh_HK | | 繁体中文(中国台湾) | zh_TW | -| 缅甸语 | my_MM | +| 缅甸语 | my_MM | 具体的使用方法请参考 [ConfigProvider 文档](/components/config-provider-cn)。 diff --git a/docs/react/migration-v5.en-US.md b/docs/react/migration-v5.en-US.md index 96c32548a7..38a4bf11b9 100644 --- a/docs/react/migration-v5.en-US.md +++ b/docs/react/migration-v5.en-US.md @@ -122,6 +122,7 @@ This document will help you upgrade from antd `4.x` version to antd `5.x` versio #### Component refactoring and removal +- Remove `locale-provider` Directory. `LocaleProvider` was removed in v4, please use `ConfigProvider` instead. - Move Comment component into `@ant-design/compatible`. - Move PageHeader component into `@ant-design/pro-components`. diff --git a/docs/react/migration-v5.zh-CN.md b/docs/react/migration-v5.zh-CN.md index dd29fed635..b84c9c08b2 100644 --- a/docs/react/migration-v5.zh-CN.md +++ b/docs/react/migration-v5.zh-CN.md @@ -114,6 +114,7 @@ title: 从 v4 到 v5 #### 组件重构与移除 +- 移除 `locale-provider` 目录。`LocaleProvider` 在 v4 中已移除,请使用 `ConfigProvider` 替代。 - 移除 Comment 组件,移至 `@ant-design/compatible` 中维护。 - 移除 PageHeader 组件,移至 `@ant-design/pro-components` 中维护。 diff --git a/index-with-locales.js b/index-with-locales.js index 16ef9d660e..173bfb7d9f 100644 --- a/index-with-locales.js +++ b/index-with-locales.js @@ -1,6 +1,6 @@ const antd = require('./components'); -const req = require.context('./components', true, /^\.\/locale\/.+_.+\.tsx?$/); +const req = require.context('./components', true, /^\.\/locale\/[A-Za-z]+_[A-Za-z]+\.tsx?$/); antd.locales = {}; diff --git a/scripts/check-cssinjs.js b/scripts/check-cssinjs.js index ff2a1f9be4..93feaa256c 100644 --- a/scripts/check-cssinjs.js +++ b/scripts/check-cssinjs.js @@ -30,7 +30,7 @@ const EmptyElement = React.createElement('div'); const styleFiles = glob.globSync( path.join( process.cwd(), - 'components/!(version|config-provider|icon|locale-provider|auto-complete|col|row|time-picker|)/style/index.?(ts|tsx)', + 'components/!(version|config-provider|icon|auto-complete|col|row|time-picker|)/style/index.?(ts|tsx)', ), ); diff --git a/scripts/collect-token-statistic.js b/scripts/collect-token-statistic.js index b127739192..7a204fe4ac 100644 --- a/scripts/collect-token-statistic.js +++ b/scripts/collect-token-statistic.js @@ -18,7 +18,7 @@ const EmptyElement = React.createElement('div'); const styleFiles = glob.globSync( path.join( process.cwd(), - 'components/!(version|config-provider|icon|locale-provider|auto-complete|col|row|time-picker|)/style/index.?(ts|tsx)', + 'components/!(version|config-provider|icon|auto-complete|col|row|time-picker|)/style/index.?(ts|tsx)', ), );