From 1697087989ee60729037b73817586cc6aacbc156 Mon Sep 17 00:00:00 2001 From: Lan Date: Wed, 3 Jun 2026 02:38:29 +0800 Subject: [PATCH] fix: localize upload status text --- src/components/common/FileUploadArea.vue | 15 ++++++++------- src/composables/useSendFlow.ts | 6 ++++-- src/i18n/locales/en-US.ts | 11 ++++++++++- src/i18n/locales/zh-CN.ts | 11 ++++++++++- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/components/common/FileUploadArea.vue b/src/components/common/FileUploadArea.vue index 40d95bf..cff37d5 100644 --- a/src/components/common/FileUploadArea.vue +++ b/src/components/common/FileUploadArea.vue @@ -119,7 +119,7 @@ : 'bg-indigo-500 hover:bg-indigo-600 text-white' ]" > - {{ retryText }} + {{ retryLabel }} @@ -177,7 +177,7 @@ const props = withDefaults(defineProps(), { totalBytes: 0, errorMessage: '', allowRetry: true, - retryText: '重试', + retryText: '', showProgressDetails: true }) @@ -188,6 +188,7 @@ const isDarkMode = useInjectedDarkMode() // 使用computed属性处理多语言文本 const placeholderText = computed(() => props.placeholder || t('send.uploadArea.placeholder')) const descriptionText = computed(() => props.description || t('send.uploadArea.description')) +const retryLabel = computed(() => props.retryText || t('send.uploadArea.retry')) const fileInput = ref(null) const isDragActive = ref(false) @@ -204,7 +205,7 @@ const displayText = computed(() => { return props.selectedFiles[0].name } if (props.selectedFiles && props.selectedFiles.length > 1) { - return `已选择 ${props.selectedFiles.length} 个文件` + return t('send.uploadArea.selectedFiles', { count: props.selectedFiles.length }) } if (props.selectedFile) { return props.selectedFile.name @@ -249,16 +250,16 @@ const statusDescription = computed(() => { return props.errorMessage } if (props.uploadStatus === 'initializing') { - return '正在初始化上传...' + return t('send.uploadArea.status.initializing') } if (props.uploadStatus === 'uploading') { - return '正在上传文件...' + return t('send.uploadArea.status.uploading') } if (props.uploadStatus === 'confirming') { - return '正在确认上传...' + return t('send.uploadArea.status.confirming') } if (isSuccess.value) { - return '上传成功!' + return t('send.uploadArea.status.success') } return descriptionText.value }) diff --git a/src/composables/useSendFlow.ts b/src/composables/useSendFlow.ts index a798816..3f6a6b8 100644 --- a/src/composables/useSendFlow.ts +++ b/src/composables/useSendFlow.ts @@ -32,8 +32,10 @@ export function useSendFlow() { const isSubmitting = ref(false) const fileHash = ref('') const sendRecords = computed(() => fileDataStore.shareData) - const uploadDescription = computed( - () => `支持各种常见格式,最大${getStorageUnit(config.value.uploadSize)}` + const uploadDescription = computed(() => + t('send.uploadArea.descriptionWithLimit', { + size: getStorageUnit(config.value.uploadSize) + }) ) const expirationOptions = computed(() => config.value.expireStyle.map((value) => ({ diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index 8f91b08..39150eb 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -215,7 +215,16 @@ export default { clickText: 'click to select files', textInput: 'Enter text to send here...', placeholder: 'Click or drag files here to upload', - description: 'Supports various common formats' + description: 'Supports various common formats', + descriptionWithLimit: 'Supports common formats, up to {size}', + retry: 'Retry', + selectedFiles: '{count} files selected', + status: { + initializing: 'Preparing upload...', + uploading: 'Uploading files...', + confirming: 'Confirming upload...', + success: 'Upload complete!' + } }, submit: 'Secure Send', submitting: 'Sending...', diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index 8ff63c0..680b1ca 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -217,7 +217,16 @@ export default { clickText: '点击选择文件', textInput: '在此输入要发送的文本...', placeholder: '点击或拖放文件到此处上传', - description: '支持各种常见格式' + description: '支持各种常见格式', + descriptionWithLimit: '支持各种常见格式,最大{size}', + retry: '重试', + selectedFiles: '已选择 {count} 个文件', + status: { + initializing: '正在初始化上传...', + uploading: '正在上传文件...', + confirming: '正在确认上传...', + success: '上传成功!' + } }, submit: '安全寄送', submitting: '发送中...',