From a08cf8ee6b996c3dddbebbd7ee846b3ccf0a2167 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Sun, 8 May 2022 11:03:56 +0800 Subject: [PATCH] i18n: modals in file manager --- public/locales/en-US/application.json | 59 +++++++ public/locales/en-US/common.json | 2 + public/locales/zh-CN/application.json | 59 +++++++ public/locales/zh-CN/common.json | 2 + src/component/FileManager/Modals.js | 245 +++++++++++++------------- src/component/Modals/Compress.js | 30 ++-- src/component/Modals/CreateShare.js | 97 ++++++---- src/component/Modals/Decompress.js | 37 ++-- src/redux/explorer/action.ts | 25 ++- 9 files changed, 372 insertions(+), 184 deletions(-) diff --git a/public/locales/en-US/application.json b/public/locales/en-US/application.json index c75ba07..f77bd09 100644 --- a/public/locales/en-US/application.json +++ b/public/locales/en-US/application.json @@ -128,5 +128,64 @@ "createShareLink": "Share", "viewDetails": "View details", "copy": "Copy" + }, + "modals": { + "processing": "Processing...", + "duplicatedObjectName": "Duplicated object name.", + "duplicatedFolderName": "Duplicated folder name.", + "taskCreated": "Task created.", + "taskCreateFailed": "{{failed}} task(s) failed to be created:{{details}}.", + "linkCopied": "Link copied.", + "getSourceLinkTitle": "Get source link", + "sourceLink": "Source link", + "folderName": "Folder name", + "create": "Create", + "fileName": "File name", + "renameDescription": "Enter the new name for <0>{{name}} :", + "newName": "New name", + "moveToTitle": "Move to", + "moveToDescription": "Move to <0>{{name}}", + "saveToTitle": "Save to", + "saveToTitleDescription": "Save to <0>{{name}}", + "deleteTitle": "Delete objects", + "deleteOneDescription": "Are you sure to delete <0>{{name}} ?", + "deleteMultipleDescription": "Are you sure to remove those {{num}} objects?", + "newRemoteDownloadTitle": "New remote download task", + "remoteDownloadURL": "Download target URL", + "remoteDownloadURLDescription": "Paste the download URL, one URL per line, support HTTP(s) / FTP / Magnet link", + "remoteDownloadDst": "Select a download destination", + "createTask": "Creat task", + "downloadTo": "Download to <0>{{name}}", + "decompressTo": "Decompress to", + "decompressToDst": "Decompress to <0>{{name}}", + "defaultEncoding": "Default", + "chineseMajorEncoding": "", + "selectEncoding": "Select the encoding for non-UTF8 characters", + "noEncodingSelected": "No encoding method selected", + "listingFiles": "Listing files...", + "listingFileError": "Failed to list files: {{message}}", + "generatingSourceLinks": "Generating source links...", + "noFileCanGenerateSourceLink": "There is no file that can be used to generate source link", + "sourceBatchSizeExceeded": "The current user group can generate source links for a maximum of {{limit}} files at the same time.", + "zipFileName": "ZIP file name", + "shareLinkShareContent": "I shared with you: {{name}} Link: {{link}}", + "shareLinkPasswordInfo": "Password: {{password}}", + "createShareLink": "Create share link", + "usePasswordProtection": "Use password protection", + "sharePassword": "Share password", + "randomlyGenerate": "Random", + "expireAutomatically": "Automatic expiration", + "downloadLimitOptions": "{{num}} downloads", + "or": "Or after", + "5minutes": "5 minutes", + "1hour": "1 hour", + "1day": "1 day", + "7days": "7 days", + "30days": "30 days", + "downloadSuffix": "", + "allowPreview": "Enable preview", + "allowPreviewDescription": "Whether to allow preview of file content from the share link", + "shareLink": "Share link", + "sendLink": "Send the link" } } \ No newline at end of file diff --git a/public/locales/en-US/common.json b/public/locales/en-US/common.json index e01c334..137c71f 100644 --- a/public/locales/en-US/common.json +++ b/public/locales/en-US/common.json @@ -8,6 +8,8 @@ "ok": "OK", "cancel": "Cancel", "select": "Select", + "copyToClipboard": "Copy", + "close": "Close", "errors": { "40020": "Wrong password or email address.", "40017": "This account has been blocked.", diff --git a/public/locales/zh-CN/application.json b/public/locales/zh-CN/application.json index 16dd0b6..6f0beed 100644 --- a/public/locales/zh-CN/application.json +++ b/public/locales/zh-CN/application.json @@ -128,5 +128,64 @@ "createShareLink": "创建分享链接", "viewDetails": "详细信息", "copy": "复制" + }, + "modals": { + "processing": "处理中...", + "duplicatedObjectName": "新名称与已有文件重复", + "duplicatedFolderName": "文件夹名称重复", + "taskCreated": "任务已创建", + "taskCreateFailed": "{{failed}} 个任务创建失败:{{details}}", + "linkCopied": "链接已复制", + "getSourceLinkTitle": "获取文件外链", + "sourceLink": "文件外链", + "folderName": "文件夹名称", + "create": "创建", + "fileName": "文件名称", + "renameDescription": "输入 <0>{{name}} 的新名称:", + "newName": "新名称", + "moveToTitle": "移动至", + "moveToDescription": "移动至 <0>{{name}}", + "saveToTitle": "保存至", + "saveToTitleDescription": "保存至 <0>{{name}}", + "deleteTitle": "删除对象", + "deleteOneDescription": "确定要删除 <0>{{name}} 吗?", + "deleteMultipleDescription": "确定要删除这 {{num}} 个对象吗?", + "newRemoteDownloadTitle": "新建离线下载任务", + "remoteDownloadURL": "文件地址", + "remoteDownloadURLDescription": "输入文件下载地址,一行一个,支持 HTTP(s) / FTP / 磁力链", + "remoteDownloadDst": "选择存储位置", + "createTask": "创建任务", + "downloadTo": "下载至 <0>{{name}}", + "decompressTo": "解压缩至", + "decompressToDst": "解压缩至 <0>{{name}}", + "defaultEncoding": "缺省", + "chineseMajorEncoding": "简体中文常见编码", + "selectEncoding": "选择 ZIP 文件特殊字符编码", + "noEncodingSelected": "未选择编码方式", + "listingFiles": "列取文件中...", + "listingFileError": "列取文件时出错:{{message}}", + "generatingSourceLinks": "生成外链中...", + "noFileCanGenerateSourceLink": "没有可以生成外链的文件", + "sourceBatchSizeExceeded": "当前用户组最大可同时为 {{limit}} 个文件生成外链", + "zipFileName": "ZIP 文件名", + "shareLinkShareContent": "我向你分享了:{{name}} 链接:{{link}}", + "shareLinkPasswordInfo": " 密码: {{password}}", + "createShareLink": "创建分享链接", + "usePasswordProtection": "使用密码保护", + "sharePassword": "分享密码", + "randomlyGenerate": "随机生成", + "expireAutomatically": "自动过期", + "downloadLimitOptions": "{{num}} 次下载", + "or": "或者", + "5minutes": "5 分钟", + "1hour": "1 小时", + "1day": "1 天", + "7days": "7 天", + "30days": "30 天", + "downloadSuffix": "后过期", + "allowPreview": "允许预览", + "allowPreviewDescription": "是否允许在分享页面预览文件内容", + "shareLink": "分享链接", + "sendLink": "发送链接" } } \ No newline at end of file diff --git a/public/locales/zh-CN/common.json b/public/locales/zh-CN/common.json index e1b5967..d4c7d62 100644 --- a/public/locales/zh-CN/common.json +++ b/public/locales/zh-CN/common.json @@ -8,6 +8,8 @@ "ok": "确定", "cancel": "取消", "select": "选择", + "copyToClipboard": "复制", + "close": "关闭", "errors": { "40020": "用户邮箱或密码错误", "40017": "该账号已被封禁", diff --git a/src/component/FileManager/Modals.js b/src/component/FileManager/Modals.js index 4a61550..c2bf3ae 100644 --- a/src/component/FileManager/Modals.js +++ b/src/component/FileManager/Modals.js @@ -2,7 +2,7 @@ import React, { Component } from "react"; import PropTypes from "prop-types"; import { connect } from "react-redux"; import PathSelector from "./PathSelector"; -import API, { baseURL } from "../../middleware/Api"; +import API from "../../middleware/Api"; import { Button, CircularProgress, @@ -18,7 +18,6 @@ import Loading from "../Modals/Loading"; import CopyDialog from "../Modals/Copy"; import CreatShare from "../Modals/CreateShare"; import { withRouter } from "react-router-dom"; -import pathHelper from "../../utils/page"; import DecompressDialog from "../Modals/Decompress"; import CompressDialog from "../Modals/Compress"; import { @@ -31,6 +30,7 @@ import { } from "../../redux/explorer"; import OptionSelector from "../Modals/OptionSelector"; import { getDownloadURL } from "../../services/file"; +import { Trans, withTranslation } from "react-i18next"; const styles = (theme) => ({ wrapper: { @@ -270,7 +270,7 @@ class ModalsCompoment extends Component { target.path === "/" ? target.path + target.name : target.path + "/" + target.name; - this.props.openLoadingDialog("处理中..."); + this.props.openLoadingDialog(this.props.t("modals.processing")); this.submitMove(); } }; @@ -303,7 +303,7 @@ class ModalsCompoment extends Component { this.props.toggleSnackbar( "top", "right", - "新名称与已有文件重复", + this.props.t("modals.duplicatedObjectName"), "warning" ); this.props.setModalsLoading(false); @@ -341,7 +341,7 @@ class ModalsCompoment extends Component { this.props.toggleSnackbar( "top", "right", - "文件夹名称重复", + this.props.t("modals.duplicatedFolderName"), "warning" ); this.props.setModalsLoading(false); @@ -382,7 +382,7 @@ class ModalsCompoment extends Component { this.props.toggleSnackbar( "top", "right", - "文件名称重复", + this.props.t("modals.duplicatedFolderName"), "warning" ); this.props.setModalsLoading(false); @@ -425,7 +425,7 @@ class ModalsCompoment extends Component { this.props.toggleSnackbar( "top", "right", - "任务已创建", + this.props.t("modals.taskCreated"), "success" ); this.onClose(); @@ -455,19 +455,22 @@ class ModalsCompoment extends Component { .then((response) => { const failed = response.data .filter((r) => r.code !== 0) - .map((r) => (r.msg + r.error ? r.error : "")); + .map((r) => r.msg + (r.error ? r.error : "")); if (failed.length > 0) { this.props.toggleSnackbar( "top", "right", - `${failed.length} 个任务创建失败:${failed.join(",")}`, + this.props.t("modals.taskCreateFailed", { + failed: failed.length, + details: failed.join(","), + }), "warning" ); } else { this.props.toggleSnackbar( "top", "right", - "任务已创建", + this.props.t("modals.taskCreated"), "success" ); } @@ -528,12 +531,17 @@ class ModalsCompoment extends Component { copySource = () => { if (navigator.clipboard) { navigator.clipboard.writeText(this.props.modalsStatus.getSource); - this.props.toggleSnackbar("top", "right", "链接已复制", "info"); + this.props.toggleSnackbar( + "top", + "right", + this.props.t("modals.linkCopied"), + "info" + ); } }; render() { - const { classes } = this.props; + const { classes, t } = this.props; return (
@@ -546,14 +554,14 @@ class ModalsCompoment extends Component { fullWidth > - 获取文件外链 + {t("modals.getSourceLinkTitle")} + - - 新建文件夹 + + {t("fileManager.newFolder")} +
@@ -580,7 +592,7 @@ class ModalsCompoment extends Component { autoFocus margin="dense" id="newFolderName" - label="文件夹名称" + label={t("modals.folderName")} type="text" value={this.state.newFolderName} onChange={(e) => this.handleInputChange(e)} @@ -589,7 +601,9 @@ class ModalsCompoment extends Component {
- +
+
+
+
+
- -
- 新建离线下载任务 + {t("modals.newRemoteDownloadTitle")} - + @@ -901,7 +894,7 @@ class ModalsCompoment extends Component { aria-labelledby="form-dialog-title" > - 选择存储位置 + {t("modals.remoteDownloadDst")} - 下载至{" "} - {this.state.selectedPathName} + ]} + />
)} - +
+
+
)} - + {shareURL === "" && (
@@ -464,7 +491,7 @@ export default function CreatShare(props) { color="secondary" disabled={props.modalsLoading} > - 创建分享链接 + {t("modals.createShareLink")} {props.modalsLoading && ( ({ contentFix: { @@ -35,6 +34,7 @@ const useStyles = makeStyles((theme) => ({ })); export default function DecompressDialog(props) { + const { t } = useTranslation(); const [selectedPath, setSelectedPath] = useState(""); const [selectedPathName, setSelectedPathName] = useState(""); @@ -72,7 +72,12 @@ export default function DecompressDialog(props) { SubmitDecompressTask(selectedPath) .then(() => { props.onClose(); - ToggleSnackbar("top", "right", "解压缩任务已创建", "success"); + ToggleSnackbar( + "top", + "right", + t("modals.taskCreated"), + "success" + ); SetModalsLoading(false); }) .catch((error) => { @@ -89,7 +94,9 @@ export default function DecompressDialog(props) { onClose={props.onClose} aria-labelledby="form-dialog-title" > - 解压送至 + + {t("modals.decompressTo")} + - 解压缩至 {selectedPathName} + ]} + /> )} - +