Skip to content

Commit

Permalink
fix: [pagination] 添加跳转按钮的国际化功能 fix #932
Browse files Browse the repository at this point in the history
  • Loading branch information
haohao_peng committed Nov 18, 2024
1 parent 6ba5229 commit 4e44f8f
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 5 deletions.
124 changes: 124 additions & 0 deletions components/locale/en-US.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
const locale = {
locale: 'en-US',
'DatePicker.placeholder': 'select date',
'DatePicker.yearPlaceholder': 'select year',
'DatePicker.quarterPlaceholder': 'select quarter',
'DatePicker.monthPlaceholder': 'select month',
'DatePicker.weekPlaceholder': 'select week',
'DatePicker.timePlaceholder': 'select time',
'DatePicker.now': 'Now',
'DatePicker.confrim': 'Ok',
'DatePicker.today': 'Today',
'DatePicker.month': 'Month',
'DatePicker.year': '',
'DatePicker.weekTitle': ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
'DatePicker.monthTitle': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
'DatePicker.rangePlaceholder': ['Start date', 'End date'],
'DatePicker.rangeYearPlaceholder': ['Start year', 'End year'],
'DatePicker.rangeMonthPlaceholder': ['Start month', 'End month'],
'DatePicker.rangeWeekPlaceholder': ['Start week', 'End week'],
'DatePicker.rangeQuarterPlaceholder': ['Start quarter', 'End quarter'],
'DatePicker.rangeTimePlaceholder': ['Start time', 'End time'],
'global.selectholder': 'Please select',
'global.placeholder': 'Please enter search content',
'global.cancel': 'Cancel',
'global.confirm': 'Ok',
'global.emptyText': 'No data',
'Button.text': 'Button',
'Progress.circleLoadingDesc': 'Loading...',
'Progress.loading': 'Loading...',
'Progress.fail': 'Load failed',
'Progress.success': 'Load successful',
'Pagination.prevPage': 'Previous',
'Pagination.nextPage': 'Next',
'Pagination.total': 'Total {page} pages {row} items',
'Pagination.page': 'Total {page} pages',
'Pagination.row': 'Total {row} items',
'Pagination.first': 'First page',
'Pagination.last': 'Last page',
'Pagination.perPage': '{size} /page',
'Pagination.order': 'Page {order}',
'Pagination.forward': 'Forward 5 pages',
'Pagination.backward': 'Backward 5 pages',
'Pagination.confirm': 'GO',
'Transfer.selectAll': 'Select all',
'Transfer.searchPlaceholder': ['Please enter search content', 'Please enter search content'],
'Transfer.leftTitle': 'Available list',
'Transfer.rightTitle': 'Selected list',
'Transfer.emptyTip': 'No data',
'Modal.okText': 'Ok',
'Modal.cancelText': 'Cancel',
'Modal.iknowText': 'I know',
'Empty.emptyText': 'No data',
'Empty.searchEmptyText': 'No results found',
'QuickSearch.placeholder': 'Please enter search content',
'QuickSearch.desc': ["Space means 'or', Enter means 'and'"],
'QuickSearch.nplDesc': 'Smart search',
'QuickSearch.emptyTip': 'No data',
'QuickSearch.or': 'Or',
'CityPicker.domestic': 'Domestic',
'CityPicker.common': 'Common',
'CityPicker.emptyText': 'No data',
'CityPicker.commonEmptyText': 'No common cities',
'CityPicker.tabsDomestic': 'Domestic',
'CityPicker.tabsInternation': 'International/China HK-MO-TW',
'CityPicker.title': 'City',
'ColorPicker.followFunctionalColor': 'Follow theme color',
'Search.placeholder': 'Please enter search content',
'Search.desc': ["Space means 'or', Enter means 'and'"],
'Search.nplDesc': 'Smart search',
'Search.emptyTip': 'No data',
'Search.viewMoreResult': "See more results for '{inputValue}'",
'Search.range': 'scope',
'Search.or': 'Or',
'Filter.filterCondition': 'Filter condition',
'Filter.commonCondition': 'Common conditions',
'Filter.schemeQuery': 'Scheme query',
'Filter.spread': 'Expand',
'Filter.packup': 'Collapse',
'Filter.filter': '',
'Filter.scheme': 'Scheme',
'Filter.unlimited': 'Unlimited',
'Filter.commonScheme': 'Common schemes',
'Filter.advancedQuery': 'Advanced query',
'Filter.schemeName': 'Scheme name',
'Filter.addCondition': 'Add condition',
'Filter.saveScheme': 'Save scheme',
'Filter.query': 'Query',
'Filter.and': 'And',
'Filter.settings': 'Settings',
'Filter.schemeNamePlaceholder': 'Please enter scheme name',
'Form.requiredMessage': 'Please enter your ',
'Table.contain': 'Contain',
'Table.notContain': 'Do not contain',
'Table.equal': 'Equal',
'Table.notEqual': 'Not equal',
'Table.isNull': 'Is null',
'Table.notIsNull': 'Is not null',
'Table.resetFilter': 'Reset',
'Table.confirmFilter': 'Ok',
'Select.selectAll': 'Select all',
'Select.seleted': 'Selected {size} items',
'Select.total': 'Total {total} items',
'Signature.clickToSign': 'Click to sign',
'Signature.pleaseWriteHere': 'Please write your signature horizontally here',
'Signature.okText': 'Ok',
'Signature.cancelText': 'Cancel',
'Signature.handwrittenSignature': 'Handwritten Signature',
'QRCode.qrCodeExpired': 'QR code expired',
'QRCode.clickRefresh': 'Refresh',
'Cascader.total': 'Total {total} items',
'BaseData.total': 'Total {total} items',
'BaseData.history': 'History',
'BaseData.favorites': 'Favorites',
'Image.close': 'Close',
'Upload.reUpload': 'Re-upload',
'Upload.uploading': 'Uploading',
'Upload.fail': 'Upload failed',
'Upload.delete': 'Delete',
'Notification.title': 'System Notification',
'TreeSelect.total': 'Total {total} items',
'ImageCropper.okText': 'Confirm Crop',
}

export default locale
1 change: 1 addition & 0 deletions components/locale/zh-CN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const locale = {
'Pagination.order': '第 {order} 页',
'Pagination.forward': '向前 5 页',
'Pagination.backward': '向后 5 页',
'Pagination.confirm': '确定',
'Transfer.selectAll': '全选',
'Transfer.searchPlaceholder': ['请输入需要搜索的内容', '请输入需要搜索的内容'],
'Transfer.leftTitle': '可选列表',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ exports[`Pagination 2.render test renders correctly 6`] = `
<button
class="kd-pagination-jumper-button"
>
GO
确定
</button>
</div>
</div>
Expand Down
11 changes: 9 additions & 2 deletions components/pagination/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,20 @@ describe('Pagination', () => {
current: 3,
},
},
localeConfig: {
locale: 'zh-CN',
localeData: {
'Pagination.confirm': 'GO',
},
},
}
const wrapper = mount(
<ConfigProvider value={paginationConfig}>
<Pagination />
<Pagination pageType="nicety" total={50} />
</ConfigProvider>,
)
expect(wrapper.find(`.kd-pagination-current-input`).at(0).prop('value')).toEqual(3)
expect(wrapper.find(`.kd-pagination-pages-item.active`).at(0).text()).toEqual('3')
expect(wrapper.find(`.kd-pagination-jumper-button`).at(0).text()).toEqual('GO')
})
})
// 9.API test
Expand Down
1 change: 1 addition & 0 deletions components/pagination/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ subtitle: 分页
| | --kd-c-pagination-sizing-border-width | - | 1px |
| spacing | --kd-c-pagination-button-spacing | - | 4px |
| | --kd-c-pagination-dropdown-item-spacing-padding-horizontal | - | 24px |
| | --kd-c-pagination-jumper-spacing-padding-horizontal | - | 4px |
2 changes: 1 addition & 1 deletion components/pagination/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ const Pagination: React.FC<IPaginationProps> = (props) => {
value={inputPage === undefined ? '' : inputPage}
/>
<button className={`${prefixCls}-jumper-button`} disabled={disabled} onClick={handleConfirmCurrentPage}>
GO
{paginationLangMsg.confirm}
</button>
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion components/pagination/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@

.@{pagination-jumper-prefix-cls}-button {
.reset-component;
width: @pagination-size;
padding: 0 @pagination-jumper-spacing;
height: @pagination-size;
margin-left: @pagination-button-spacing;
display: inline-flex;
Expand Down
1 change: 1 addition & 0 deletions components/pagination/style/token.less
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// spacing
@pagination-button-spacing: var(~'@{pagination-custom-prefix}-button-spacing', 4px);
@pagination-dropdown-item-spacing-horizontal: var(~'@{pagination-custom-prefix}-dropdown-item-spacing-padding-horizontal', 24px);
@pagination-jumper-spacing: var(~'@{pagination-custom-prefix}-jumper-spacing-padding-horizontal', 4px);



Expand Down

0 comments on commit 4e44f8f

Please sign in to comment.