diff --git a/src/packages/__VUE/animate/demo.vue b/src/packages/__VUE/animate/demo.vue index b3c256b32d..5de5d94f88 100644 --- a/src/packages/__VUE/animate/demo.vue +++ b/src/packages/__VUE/animate/demo.vue @@ -112,6 +112,7 @@ const translate = useTranslate({ once: 'Once', times: 'Several times', basic: 'Loop animation', + click: 'Click', FRTL: 'From right to left', FLTR: 'From left to right', FTTB: 'From top to bottom', diff --git a/src/packages/__VUE/button/demo.vue b/src/packages/__VUE/button/demo.vue index 7c7ccdb5e3..dc57b81a3f 100644 --- a/src/packages/__VUE/button/demo.vue +++ b/src/packages/__VUE/button/demo.vue @@ -40,7 +40,7 @@ import Icon from './demo/icon.vue'; import Size from './demo/size.vue'; import Block from './demo/block.vue'; import Color from './demo/color.vue'; -const translate = useTranslate<['type', 'plain', 'disabled', 'shape', 'loading', 'icon', 'size', 'block', 'color']>({ +const translate = useTranslate({ 'zh-CN': { type: '按钮类型', plain: '朴素按钮', diff --git a/src/packages/__VUE/calendar/demo.vue b/src/packages/__VUE/calendar/demo.vue index bad83ebad8..8fc1b46eba 100644 --- a/src/packages/__VUE/calendar/demo.vue +++ b/src/packages/__VUE/calendar/demo.vue @@ -328,6 +328,7 @@ const translate = useTranslate({ range: 'Select Date Range', multiple: 'Select Multiple Date', week: 'Select Week', + disabledDate: 'Disabled Date', conjunction: '-', custom_btn: 'Custom Button', diff --git a/src/packages/__VUE/cell/demo.vue b/src/packages/__VUE/cell/demo.vue index 6f3a507236..c1c50b089e 100644 --- a/src/packages/__VUE/cell/demo.vue +++ b/src/packages/__VUE/cell/demo.vue @@ -121,6 +121,7 @@ const translate = useTranslate({ title7: 'Vertical Center', title8: 'Use Slots title', title9: 'Size setting large', + title10: 'Desc Slot', link: 'Link', urlJump: 'URL Jump', routerJump: 'Router Jump ’/‘ ', diff --git a/src/packages/__VUE/circleprogress/demo.vue b/src/packages/__VUE/circleprogress/demo.vue index f7f583c160..12d165c964 100644 --- a/src/packages/__VUE/circleprogress/demo.vue +++ b/src/packages/__VUE/circleprogress/demo.vue @@ -52,6 +52,7 @@ const translate = useTranslate({ customWidth: 'Custom Width', Gradient: 'Gradient', custom: 'custom', + customSize: 'Custom Size', customContent: 'Custom Content', dynamicChange: 'Dynamic Change', reduce: 'reduce', diff --git a/src/packages/__VUE/comment/demo.vue b/src/packages/__VUE/comment/demo.vue index 88b11c0fee..df88a3f43b 100644 --- a/src/packages/__VUE/comment/demo.vue +++ b/src/packages/__VUE/comment/demo.vue @@ -74,7 +74,7 @@ const translate = useTranslate({ basic: 'Basic Usage', single: 'Single Line Image', multiRow: 'Multi Line Image ', - review: 'Additional Review' + additionalReviewd: 'Additional Review' } }); let cmt = ref({}); diff --git a/src/packages/__VUE/grid/demo.vue b/src/packages/__VUE/grid/demo.vue index 57a8f4e3d5..5f27a3b0d8 100644 --- a/src/packages/__VUE/grid/demo.vue +++ b/src/packages/__VUE/grid/demo.vue @@ -178,7 +178,7 @@ const translate = useTranslate({ square: 'Square', gutter: 'Gutter', reverse: 'Reverse', - horizontal: 'Horizontal', + Horizontal: 'Horizontal', iconStyle: 'Icon Style', route: 'Route', customContent: 'Custom Content', diff --git a/src/packages/__VUE/image/demo.vue b/src/packages/__VUE/image/demo.vue index 3d8063e29a..3346e802ad 100644 --- a/src/packages/__VUE/image/demo.vue +++ b/src/packages/__VUE/image/demo.vue @@ -113,7 +113,7 @@ const translate = useTranslate({ circle: '圆形图片', loading: '加载中提示', error: '加载失败', - lay: '懒加载' + lazy: '懒加载' }, 'en-US': { basic: 'Basic Usage', diff --git a/src/packages/__VUE/searchbar/demo.vue b/src/packages/__VUE/searchbar/demo.vue index d0f1801ac9..7e85632deb 100644 --- a/src/packages/__VUE/searchbar/demo.vue +++ b/src/packages/__VUE/searchbar/demo.vue @@ -71,7 +71,6 @@ const translate = useTranslate({ basic7: '自定义清除图标 icon', word1: '标签', word2: '搜索', - title3: '标题3', shape: '设置搜索框形状' }, 'en-US': { diff --git a/src/packages/__VUE/uploader/demo.vue b/src/packages/__VUE/uploader/demo.vue index a47f936741..a8b316c337 100644 --- a/src/packages/__VUE/uploader/demo.vue +++ b/src/packages/__VUE/uploader/demo.vue @@ -67,7 +67,13 @@ const translate = useTranslate({ title11: '手动执行上传', title12: '禁用状态', title13: '自定义 xhr 上传方式(before-xhr-upload)', - title14: '手动清空上传' + title14: '手动清空上传', + ready: '准备完成', + readyUpload: '准备上传', + waitingUpload: '等待上传', + uploading: '上传中', + success: '上传成功', + error: '上传失败' }, 'en-US': { basic: 'Basic Usage', @@ -85,7 +91,13 @@ const translate = useTranslate({ title11: 'Manual upload', title12: 'Disabled state', title13: 'Customize XHR upload (before-xhr-upload)', - title14: 'Clear upload manually' + title14: 'Clear upload manually', + ready: 'Ready', + readyUpload: 'Ready to upload', + waitingUpload: 'Waiting for upload', + uploading: 'Uploading', + success: 'Upload successful', + error: 'Upload failed' } }); const uploadUrl = 'https://my-json-server.typicode.com/linrufeng/demo/posts'; diff --git a/src/sites/assets/util/useTranslate.ts b/src/sites/assets/util/useTranslate.ts index 6582e55e3c..be6e7e7d5a 100644 --- a/src/sites/assets/util/useTranslate.ts +++ b/src/sites/assets/util/useTranslate.ts @@ -1,20 +1,20 @@ import Locale from '@/packages/locale'; import { useLocale } from '@/packages/utils/useLocale'; export const currentLang = Locale.currentLang; -// @type-challenges -type TupleToUnion = T[number]; -export const useTranslate = (object: { - 'zh-CN': { - [key in TupleToUnion]: string | string[] | Function; - }; - 'en-US': { - [key in TupleToUnion]: string | string[] | Function; - }; + +export const useTranslate = < + T1 extends { + [key: string]: any; + }, + T2 extends T1 +>(object: { + 'zh-CN': T1; + 'en-US': T2; }) => { for (const [key, value] of Object.entries(object)) { Locale.merge(key, value); } - return useLocale>(); + return useLocale, number | symbol>>(); }; export const translateChange = () => {