diff --git a/public/locales/en-US/application.json b/public/locales/en-US/application.json index c3d8ad6..c75ba07 100644 --- a/public/locales/en-US/application.json +++ b/public/locales/en-US/application.json @@ -83,6 +83,50 @@ "rename": "Rename", "move": "Move", "delete": "Remove", - "moreActions": "More actions..." + "moreActions": "More actions...", + "refresh": "Refresh", + "compress": "Compress", + "newFolder": "New folder", + "newFile": "New file", + "showFullPath": "Show full path", + "listView": "List view", + "gridViewSmall": "Grid view (no preview)", + "gridViewLarge": "Grid view", + "paginationSize": "Pagination", + "paginationOption": "{{option}} / page", + "noPagination": "No pagination", + "sortMethod": "Sort by", + "sortMethods": { + "A-Z": "A-Z", + "Z-A": "Z-A", + "oldestUploaded": "Oldest uploaded", + "newestUploaded": "Newest uploaded", + "oldestModified": "Oldest modified", + "newestModified": "Newest modified", + "smallest": "Smallest", + "largest": "Largest" + }, + "shareCreateBy": "Created by {{nick}}", + "name": "Name", + "size": "Size", + "lastModified": "Last modified", + "backToParentFolder": "Back to the parent", + "folders": "Folders", + "files": "Files", + "listError": ":( Failed to lis files", + "dropFileHere": "Drag and drop the file here", + "orClickUploadButton": "Or click the \"Upload File\" button at the bottom right to add a file", + "nothingFound": "Nothing was found", + "uploadFiles": "Upload files", + "uploadFolder": "Upload folder", + "newRemoteDownloads": "New remote download", + "enter": "Enter", + "getSourceLink": "Get source link", + "getSourceLinkInBatch": "Get source links", + "createRemoteDownloadForTorrent": "New remote download", + "decompress": "Decompress", + "createShareLink": "Share", + "viewDetails": "View details", + "copy": "Copy" } } \ No newline at end of file diff --git a/public/locales/zh-CN/application.json b/public/locales/zh-CN/application.json index 4069e92..16dd0b6 100644 --- a/public/locales/zh-CN/application.json +++ b/public/locales/zh-CN/application.json @@ -83,6 +83,50 @@ "rename": "重命名", "move": "移动", "delete": "删除", - "moreActions": "更多操作" + "moreActions": "更多操作", + "refresh": "刷新", + "compress": "压缩", + "newFolder": "创建文件夹", + "newFile": "创建文件", + "showFullPath": "显示路径", + "listView": "列表展示", + "gridViewSmall": "小图标展示", + "gridViewLarge": "大图标展示", + "paginationSize": "分页大小", + "paginationOption": "{{option}} / 页", + "noPagination": "不分页", + "sortMethod": "排序方式", + "sortMethods": { + "A-Z": "A-Z", + "Z-A": "Z-A", + "oldestUploaded": "最早上传", + "newestUploaded": "最新上传", + "oldestModified": "最早修改", + "newestModified": "最新修改", + "smallest": "最小", + "largest": "最大" + }, + "shareCreateBy": "由 {{nick}} 创建", + "name": "名称", + "size": "大小", + "lastModified": "修改日期", + "backToParentFolder": "上级目录", + "folders": "文件夹", + "files": "文件", + "listError": ":( 请求时出现错误", + "dropFileHere": "拖拽文件至此", + "orClickUploadButton": "或点击右下方“上传文件”按钮添加文件", + "nothingFound": "什么都没有找到", + "uploadFiles": "上传文件", + "uploadFolder": "上传目录", + "newRemoteDownloads": "离线下载", + "enter": "进入", + "getSourceLink": "获取外链", + "getSourceLinkInBatch": "批量获取外链", + "createRemoteDownloadForTorrent": "创建离线下载任务", + "decompress": "解压缩", + "createShareLink": "创建分享链接", + "viewDetails": "详细信息", + "copy": "复制" } } \ No newline at end of file diff --git a/src/component/FileManager/ContextMenu.js b/src/component/FileManager/ContextMenu.js index fb12a18..0c100e7 100644 --- a/src/component/FileManager/ContextMenu.js +++ b/src/component/FileManager/ContextMenu.js @@ -61,6 +61,7 @@ import { openFileSelector, openFolderSelector, } from "../../redux/viewUpdate/action"; +import { withTranslation } from "react-i18next"; const styles = () => ({ propover: {}, @@ -239,7 +240,7 @@ class ContextMenuCompoment extends Component { }; render() { - const { classes } = this.props; + const { classes, t } = this.props; const user = Auth.GetUser(); const isHomePage = pathHelper.isHomePage(this.props.location.pathname); const emptyMenuList = { @@ -327,7 +328,9 @@ class ContextMenuCompoment extends Component { - 刷新 + + {t("fileManager.refresh")} + - 上传文件 + {t("fileManager.uploadFiles")} - 上传目录 + {t("fileManager.uploadFolder")} {user.group.allowRemoteDownload && ( @@ -363,7 +366,7 @@ class ContextMenuCompoment extends Component { - 离线下载 + {t("fileManager.newRemoteDownloads")} )} @@ -379,7 +382,7 @@ class ContextMenuCompoment extends Component { - 创建文件夹 + {t("fileManager.newFolder")} - 创建文件 + {t("fileManager.newFile")} @@ -406,7 +409,7 @@ class ContextMenuCompoment extends Component { - 进入 + {t("fileManager.enter")} {isHomePage && ( @@ -430,7 +433,7 @@ class ContextMenuCompoment extends Component { - 打开 + {t("fileManager.open")} @@ -448,7 +451,7 @@ class ContextMenuCompoment extends Component { - 下载 + {t("fileManager.download")} {isHomePage && ( @@ -467,7 +470,7 @@ class ContextMenuCompoment extends Component { - 打包下载 + {t("fileManager.batchDownload")} )} @@ -488,8 +491,12 @@ class ContextMenuCompoment extends Component { {this.props.isMultiple || (this.props.withFolder && !this.props.withFile) - ? "批量获取外链" - : "获取外链"} + ? t( + "fileManager.getSourceLinkInBatch" + ) + : t( + "fileManager.getSourceLink" + )} )} @@ -509,7 +516,9 @@ class ContextMenuCompoment extends Component { - 创建离线下载任务 + {t( + "fileManager.createRemoteDownloadForTorrent" + )} )} @@ -528,7 +537,7 @@ class ContextMenuCompoment extends Component { - 解压缩 + {t("fileManager.decompress")} )} @@ -544,7 +553,7 @@ class ContextMenuCompoment extends Component { - 创建压缩文件 + {t("fileManager.compress")} )} @@ -558,7 +567,7 @@ class ContextMenuCompoment extends Component { - 创建分享链接 + {t("fileManager.createShareLink")} )} @@ -574,7 +583,7 @@ class ContextMenuCompoment extends Component { - 详细信息 + {t("fileManager.viewDetails")} )} @@ -595,7 +604,7 @@ class ContextMenuCompoment extends Component { - 重命名 + {t("fileManager.rename")} {!this.props.search && ( @@ -609,7 +618,7 @@ class ContextMenuCompoment extends Component { - 复制 + {t("fileManager.copy")} )} @@ -628,7 +637,7 @@ class ContextMenuCompoment extends Component { - 移动 + {t("fileManager.move")} )} @@ -645,7 +654,7 @@ class ContextMenuCompoment extends Component { - 删除 + {t("fileManager.delete")} @@ -666,6 +675,6 @@ ContextMenuCompoment.propTypes = { const ContextMenu = connect( mapStateToProps, mapDispatchToProps -)(withStyles(styles)(withRouter(ContextMenuCompoment))); +)(withStyles(styles)(withRouter(withTranslation()(ContextMenuCompoment)))); export default ContextMenu; diff --git a/src/component/FileManager/Explorer.js b/src/component/FileManager/Explorer.js index 4aaee60..5a12abf 100644 --- a/src/component/FileManager/Explorer.js +++ b/src/component/FileManager/Explorer.js @@ -13,7 +13,11 @@ import TableSortLabel from "@material-ui/core/TableSortLabel"; import classNames from "classnames"; import React, { useCallback, useEffect, useMemo } from "react"; import { configure, GlobalHotKeys } from "react-hotkeys"; -import explorer, { changeContextMenu, openRemoveDialog, setSelectedTarget } from "../../redux/explorer"; +import explorer, { + changeContextMenu, + openRemoveDialog, + setSelectedTarget, +} from "../../redux/explorer"; import { isMac } from "../../utils"; import pathHelper from "../../utils/page"; import ContextMenu from "./ContextMenu"; @@ -24,6 +28,7 @@ import { useDispatch, useSelector } from "react-redux"; import { useLocation } from "react-router"; import { usePagination } from "../../hooks/pagination"; import { makeStyles } from "@material-ui/core/styles"; +import { useTranslation } from "react-i18next"; const useStyles = makeStyles((theme) => ({ paper: { @@ -117,6 +122,7 @@ const keyMap = { }; export default function Explorer({ share }) { + const { t } = useTranslation("application", { keyPrefix: "fileManager" }); const location = useLocation(); const dispatch = useDispatch(); const selected = useSelector((state) => state.explorer.selected); @@ -232,7 +238,7 @@ export default function Explorer({ share }) { ); }} > - 名称 + {t("name")} {sortMethod === "namePos" || sortMethod === "nameRev" ? ( @@ -260,7 +266,7 @@ export default function Explorer({ share }) { ); }} > - 大小 + {t("size")} {sortMethod === "sizePos" || sortMethod === "sizeRes" ? ( @@ -290,7 +296,7 @@ export default function Explorer({ share }) { ); }} > - 修改日期 + {t("lastModified")} {sortMethod === "modifyTimePos" || sortMethod === "modifyTimeRev" ? ( @@ -308,7 +314,7 @@ export default function Explorer({ share }) { )} @@ -329,7 +335,7 @@ export default function Explorer({ share }) { ), - [dirList, fileList, path, sortMethod, ChangeSortMethod] + [dirList, fileList, path, sortMethod, ChangeSortMethod, classes] ); const normalView = useMemo( @@ -342,7 +348,7 @@ export default function Explorer({ share }) { variant="body2" className={classes.typeHeader} > - 文件夹 + {t("folders")} - 文件 + {t("files")} - :( 请求时出现错误 + {t("listError")} )} {((search && @@ -464,7 +470,7 @@ export default function Explorer({ share }) { fileList.length === 0 && !loading && !navigatorError && - !isHomePage)) && } + !isHomePage)) && } {showView && view} ); diff --git a/src/component/FileManager/Navigator/Navigator.js b/src/component/FileManager/Navigator/Navigator.js index bcfea13..7d02b1a 100644 --- a/src/component/FileManager/Navigator/Navigator.js +++ b/src/component/FileManager/Navigator/Navigator.js @@ -38,6 +38,7 @@ import { FilePlus } from "mdi-material-ui"; import SubActions from "./SubActions"; import { setCurrentPolicy } from "../../../redux/explorer/action"; import { list } from "../../../services/navigate"; +import { withTranslation } from "react-i18next"; const mapStateToProps = (state) => { return { @@ -324,7 +325,7 @@ class NavigatorComponent extends Component { }; render() { - const { classes } = this.props; + const { classes, t } = this.props; const isHomePage = pathHelper.isHomePage(this.props.location.pathname); const user = Auth.GetUser(); @@ -340,7 +341,7 @@ class NavigatorComponent extends Component { - 刷新 + {t("fileManager.refresh")} {!this.props.search && isHomePage && (
@@ -349,7 +350,7 @@ class NavigatorComponent extends Component { - 分享 + {t("fileManager.share")} {user.group.compress && ( - 压缩 + {t("fileManager.compress")} )} @@ -368,13 +369,13 @@ class NavigatorComponent extends Component { - 创建文件夹 + {t("fileManager.newFolder")} this.performAction("newFile")}> - 创建文件 + {t("fileManager.newFile")}
)} @@ -404,7 +405,7 @@ class NavigatorComponent extends Component { - {/* */} ({ sideButton: { @@ -23,17 +24,19 @@ const useStyles = makeStyles((theme) => ({ const sortOptions = [ "A-Z", "Z-A", - "最早上传", - "最新上传", - "最早修改", - "最新修改", - "最小", - "最大", + "oldestUploaded", + "newestUploaded", + "oldestModified", + "newestModified", + "smallest", + "largest", ]; const paginationOption = ["50", "100", "200", "500", "1000"]; export default function SubActions({ isSmall, inherit }) { + const { t } = useTranslation("application", { keyPrefix: "fileManager" }); + const { t: vasT } = useTranslation("application", { keyPrefix: "vas" }); const dispatch = useDispatch(); const viewMethod = useSelector( (state) => state.viewUpdate.explorerViewMethod @@ -101,7 +104,7 @@ export default function SubActions({ isSmall, inherit }) { <> {viewMethod === "icon" && ( handlePaginationChange(parseInt(option))} > - {`${option} / 页`} + {t("paginationOption", { option })} ))} handlePaginationChange(-1)} > - 不分页 + {t("noPagination")} handleMenuItemClick(event, index)} > - {option} + {t("sortMethods." + option)} ))} {share && ( SetShareUserPopover(e.currentTarget)} style={{ padding: 5 }}