Skip to content

Commit

Permalink
chore: Remove locale-provider (ant-design#41289)
Browse files Browse the repository at this point in the history
* chore: rm locale-receiver

* chore: export useLocale in locale

* chore: comment

* chore: rm locale-provider dir

* docs: rm locale-provider in migration document

* chore: fix regexp

---------

Co-authored-by: MadCcc <[email protected]>
  • Loading branch information
li-jia-nan and MadCcc authored Mar 21, 2023
1 parent f829e40 commit f6c2354
Show file tree
Hide file tree
Showing 30 changed files with 30 additions and 40 deletions.
2 changes: 1 addition & 1 deletion components/calendar/generateCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
5 changes: 2 additions & 3 deletions components/date-picker/__tests__/other.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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(
<LocaleProvider locale={myLocale as Locale}>
<ConfigProvider locale={myLocale as Locale}>
<Picker value={date} {...props} />
</LocaleProvider>,
</ConfigProvider>,
);
expect(container.firstChild).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion components/empty/index.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion components/form/FormItemLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 0 additions & 6 deletions components/locale-provider/LocaleReceiver.ts

This file was deleted.

6 changes: 0 additions & 6 deletions components/locale-provider/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions components/locale/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion components/locale/my_MM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion components/modal/ConfirmDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion components/modal/PurePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion components/pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion components/popconfirm/PurePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion components/qrcode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion components/time-picker/locale/my_MM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ const locale: TimePickerLocale = {
rangePlaceholder: ['စတင်ချိန်', 'ကုန်ဆုံးချိန်'],
};

export default locale;
export default locale;
2 changes: 1 addition & 1 deletion components/tour/panelRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion components/transfer/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<RecordType> = {
Expand Down
2 changes: 1 addition & 1 deletion components/transfer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion components/upload/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion docs/react/i18n.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ return (
| 简体中文 | zh_CN |
| 繁体中文(中国香港) | zh_HK |
| 繁体中文(中国台湾) | zh_TW |
| 缅甸语 | my_MM |
| 缅甸语 | my_MM |

具体的使用方法请参考 [ConfigProvider 文档](/components/config-provider-cn)

Expand Down
1 change: 1 addition & 0 deletions docs/react/migration-v5.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
1 change: 1 addition & 0 deletions docs/react/migration-v5.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ title: 从 v4 到 v5

#### 组件重构与移除

- 移除 `locale-provider` 目录。`LocaleProvider` 在 v4 中已移除,请使用 `ConfigProvider` 替代。
- 移除 Comment 组件,移至 `@ant-design/compatible` 中维护。
- 移除 PageHeader 组件,移至 `@ant-design/pro-components` 中维护。

Expand Down
2 changes: 1 addition & 1 deletion index-with-locales.js
Original file line number Diff line number Diff line change
@@ -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 = {};

Expand Down
2 changes: 1 addition & 1 deletion scripts/check-cssinjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
),
);

Expand Down
2 changes: 1 addition & 1 deletion scripts/collect-token-statistic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
),
);

Expand Down

0 comments on commit f6c2354

Please sign in to comment.