i18n: file manager

This commit is contained in:
HFO4 2022-05-08 10:53:05 +08:00
parent 358687157c
commit f2f8d7c43a
6 changed files with 167 additions and 64 deletions

View File

@ -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"
}
}

View File

@ -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": "复制"
}
}

View File

@ -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 {
<StyledListItemIcon>
<RefreshIcon />
</StyledListItemIcon>
<Typography variant="inherit">刷新</Typography>
<Typography variant="inherit">
{t("fileManager.refresh")}
</Typography>
</MenuItem>
<Divider className={classes.divider} />
<MenuItem
@ -338,7 +341,7 @@ class ContextMenuCompoment extends Component {
<UploadIcon />
</StyledListItemIcon>
<Typography variant="inherit">
上传文件
{t("fileManager.uploadFiles")}
</Typography>
</MenuItem>
<MenuItem
@ -349,7 +352,7 @@ class ContextMenuCompoment extends Component {
<FolderUpload />
</StyledListItemIcon>
<Typography variant="inherit">
上传目录
{t("fileManager.uploadFolder")}
</Typography>
</MenuItem>
{user.group.allowRemoteDownload && (
@ -363,7 +366,7 @@ class ContextMenuCompoment extends Component {
<DownloadIcon />
</StyledListItemIcon>
<Typography variant="inherit">
离线下载
{t("fileManager.newRemoteDownloads")}
</Typography>
</MenuItem>
)}
@ -379,7 +382,7 @@ class ContextMenuCompoment extends Component {
<NewFolderIcon />
</StyledListItemIcon>
<Typography variant="inherit">
创建文件夹
{t("fileManager.newFolder")}
</Typography>
</MenuItem>
<MenuItem
@ -392,7 +395,7 @@ class ContextMenuCompoment extends Component {
<FilePlus />
</StyledListItemIcon>
<Typography variant="inherit">
创建文件
{t("fileManager.newFile")}
</Typography>
</MenuItem>
</div>
@ -406,7 +409,7 @@ class ContextMenuCompoment extends Component {
<OpenFolderIcon />
</StyledListItemIcon>
<Typography variant="inherit">
进入
{t("fileManager.enter")}
</Typography>
</MenuItem>
{isHomePage && (
@ -430,7 +433,7 @@ class ContextMenuCompoment extends Component {
<OpenIcon />
</StyledListItemIcon>
<Typography variant="inherit">
打开
{t("fileManager.open")}
</Typography>
</MenuItem>
</div>
@ -448,7 +451,7 @@ class ContextMenuCompoment extends Component {
<DownloadIcon />
</StyledListItemIcon>
<Typography variant="inherit">
下载
{t("fileManager.download")}
</Typography>
</MenuItem>
{isHomePage && (
@ -467,7 +470,7 @@ class ContextMenuCompoment extends Component {
<DownloadIcon />
</StyledListItemIcon>
<Typography variant="inherit">
打包下载
{t("fileManager.batchDownload")}
</Typography>
</MenuItem>
)}
@ -488,8 +491,12 @@ class ContextMenuCompoment extends Component {
{this.props.isMultiple ||
(this.props.withFolder &&
!this.props.withFile)
? "批量获取外链"
: "获取外链"}
? t(
"fileManager.getSourceLinkInBatch"
)
: t(
"fileManager.getSourceLink"
)}
</Typography>
</MenuItem>
)}
@ -509,7 +516,9 @@ class ContextMenuCompoment extends Component {
<MagnetOn />
</StyledListItemIcon>
<Typography variant="inherit">
创建离线下载任务
{t(
"fileManager.createRemoteDownloadForTorrent"
)}
</Typography>
</MenuItem>
)}
@ -528,7 +537,7 @@ class ContextMenuCompoment extends Component {
<Unarchive />
</StyledListItemIcon>
<Typography variant="inherit">
解压缩
{t("fileManager.decompress")}
</Typography>
</MenuItem>
)}
@ -544,7 +553,7 @@ class ContextMenuCompoment extends Component {
<Archive />
</StyledListItemIcon>
<Typography variant="inherit">
创建压缩文件
{t("fileManager.compress")}
</Typography>
</MenuItem>
)}
@ -558,7 +567,7 @@ class ContextMenuCompoment extends Component {
<ShareIcon />
</StyledListItemIcon>
<Typography variant="inherit">
创建分享链接
{t("fileManager.createShareLink")}
</Typography>
</MenuItem>
)}
@ -574,7 +583,7 @@ class ContextMenuCompoment extends Component {
<InfoOutlined />
</StyledListItemIcon>
<Typography variant="inherit">
详细信息
{t("fileManager.viewDetails")}
</Typography>
</MenuItem>
)}
@ -595,7 +604,7 @@ class ContextMenuCompoment extends Component {
<RenameIcon />
</StyledListItemIcon>
<Typography variant="inherit">
重命名
{t("fileManager.rename")}
</Typography>
</MenuItem>
{!this.props.search && (
@ -609,7 +618,7 @@ class ContextMenuCompoment extends Component {
<FileCopyIcon />
</StyledListItemIcon>
<Typography variant="inherit">
复制
{t("fileManager.copy")}
</Typography>
</MenuItem>
)}
@ -628,7 +637,7 @@ class ContextMenuCompoment extends Component {
<MoveIcon />
</StyledListItemIcon>
<Typography variant="inherit">
移动
{t("fileManager.move")}
</Typography>
</MenuItem>
)}
@ -645,7 +654,7 @@ class ContextMenuCompoment extends Component {
<DeleteIcon />
</StyledListItemIcon>
<Typography variant="inherit">
删除
{t("fileManager.delete")}
</Typography>
</MenuItem>
</div>
@ -666,6 +675,6 @@ ContextMenuCompoment.propTypes = {
const ContextMenu = connect(
mapStateToProps,
mapDispatchToProps
)(withStyles(styles)(withRouter(ContextMenuCompoment)));
)(withStyles(styles)(withRouter(withTranslation()(ContextMenuCompoment))));
export default ContextMenu;

View File

@ -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" ? (
<span className={classes.visuallyHidden}>
@ -260,7 +266,7 @@ export default function Explorer({ share }) {
);
}}
>
大小
{t("size")}
{sortMethod === "sizePos" ||
sortMethod === "sizeRes" ? (
<span className={classes.visuallyHidden}>
@ -290,7 +296,7 @@ export default function Explorer({ share }) {
);
}}
>
修改日期
{t("lastModified")}
{sortMethod === "modifyTimePos" ||
sortMethod === "modifyTimeRev" ? (
<span className={classes.visuallyHidden}>
@ -308,7 +314,7 @@ export default function Explorer({ share }) {
<ObjectIcon
file={{
type: "up",
name: "上级目录",
name: t("backToParentFolder"),
}}
/>
)}
@ -329,7 +335,7 @@ export default function Explorer({ share }) {
</TableBody>
</Table>
),
[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")}
</Typography>
<Grid
data-clickAway={"true"}
@ -374,7 +380,7 @@ export default function Explorer({ share }) {
variant="body2"
className={classes.typeHeader}
>
文件
{t("files")}
</Typography>
<Grid
data-clickAway={"true"}
@ -427,7 +433,7 @@ export default function Explorer({ share }) {
{navigatorError && (
<Paper elevation={1} className={classes.errorBox}>
<Typography variant="h5" component="h3">
:( 请求时出现错误
{t("listError")}
</Typography>
<Typography
color={"textSecondary"}
@ -451,8 +457,8 @@ export default function Explorer({ share }) {
!loading &&
!navigatorError && (
<Nothing
primary={"拖拽文件至此"}
secondary={"或点击右下方“上传文件”按钮添加文件"}
primary={t("dropFileHere")}
secondary={t("orClickUploadButton")}
/>
)}
{((search &&
@ -464,7 +470,7 @@ export default function Explorer({ share }) {
fileList.length === 0 &&
!loading &&
!navigatorError &&
!isHomePage)) && <Nothing primary={"什么都没有找到"} />}
!isHomePage)) && <Nothing primary={t("nothingFound")} />}
{showView && view}
</div>
);

View File

@ -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 {
<ListItemIcon>
<RefreshIcon />
</ListItemIcon>
刷新
{t("fileManager.refresh")}
</MenuItem>
{!this.props.search && isHomePage && (
<div>
@ -349,7 +350,7 @@ class NavigatorComponent extends Component {
<ListItemIcon>
<ShareIcon />
</ListItemIcon>
分享
{t("fileManager.share")}
</MenuItem>
{user.group.compress && (
<MenuItem
@ -358,7 +359,7 @@ class NavigatorComponent extends Component {
<ListItemIcon>
<Archive />
</ListItemIcon>
压缩
{t("fileManager.compress")}
</MenuItem>
)}
<Divider />
@ -368,13 +369,13 @@ class NavigatorComponent extends Component {
<ListItemIcon>
<NewFolderIcon />
</ListItemIcon>
创建文件夹
{t("fileManager.newFolder")}
</MenuItem>
<MenuItem onClick={() => this.performAction("newFile")}>
<ListItemIcon>
<FilePlus />
</ListItemIcon>
创建文件
{t("fileManager.newFile")}
</MenuItem>
</div>
)}
@ -404,7 +405,7 @@ class NavigatorComponent extends Component {
<span>
<PathButton
more
title="显示路径"
title={t("fileManager.showFullPath")}
onClick={this.showHiddenPath}
/>
<Menu
@ -424,10 +425,6 @@ class NavigatorComponent extends Component {
/>
</Menu>
<RightIcon className={classes.rightIcon} />
{/* <Button component="span" onClick={(e)=>this.navigateTo(e,this.state.folders.length-1)}>
{this.state.folders.slice(-1)}
<ExpandMore className={classes.expandMore}/>
</Button> */}
<PathButton
folder={this.state.folders.slice(-1)}
path={
@ -497,6 +494,6 @@ NavigatorComponent.propTypes = {
const Navigator = connect(
mapStateToProps,
mapDispatchToProps
)(withStyles(styles)(withRouter(NavigatorComponent)));
)(withStyles(styles)(withRouter(withTranslation()(NavigatorComponent))));
export default Navigator;

View File

@ -12,6 +12,7 @@ import { changeSortMethod } from "../../../redux/explorer/action";
import { FormatPageBreak } from "mdi-material-ui";
import pathHelper from "../../../utils/page";
import { changePageSize } from "../../../redux/viewUpdate/action";
import { useTranslation } from "react-i18next";
const useStyles = makeStyles((theme) => ({
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" && (
<IconButton
title="列表展示"
title={t("listView")}
className={classes.sideButton}
onClick={toggleViewMethod}
color={inherit ? "inherit" : "default"}
@ -111,7 +114,7 @@ export default function SubActions({ isSmall, inherit }) {
)}
{viewMethod === "list" && (
<IconButton
title="小图标展示"
title={t("gridViewSmall")}
className={classes.sideButton}
onClick={toggleViewMethod}
color={inherit ? "inherit" : "default"}
@ -122,7 +125,7 @@ export default function SubActions({ isSmall, inherit }) {
{viewMethod === "smallIcon" && (
<IconButton
title="大图标展示"
title={t("gridViewLarge")}
className={classes.sideButton}
onClick={toggleViewMethod}
color={inherit ? "inherit" : "default"}
@ -133,7 +136,7 @@ export default function SubActions({ isSmall, inherit }) {
{!isMobile && (
<IconButton
title="分页大小"
title={t("paginationSize")}
className={classes.sideButton}
onClick={showPaginationOptions}
color={inherit ? "inherit" : "default"}
@ -153,19 +156,19 @@ export default function SubActions({ isSmall, inherit }) {
selected={option === pageSize.toString()}
onClick={() => handlePaginationChange(parseInt(option))}
>
{`${option} / 页`}
{t("paginationOption", { option })}
</MenuItem>
))}
<MenuItem
selected={pageSize === -1}
onClick={() => handlePaginationChange(-1)}
>
不分页
{t("noPagination")}
</MenuItem>
</Menu>
<IconButton
title="排序方式"
title={t("sortMethod")}
className={classes.sideButton}
onClick={showSortOptions}
color={inherit ? "inherit" : "default"}
@ -186,13 +189,13 @@ export default function SubActions({ isSmall, inherit }) {
selected={index === selectedIndex}
onClick={(event) => handleMenuItemClick(event, index)}
>
{option}
{t("sortMethods." + option)}
</MenuItem>
))}
</Menu>
{share && (
<IconButton
title={"由 " + share.creator.nick + " 创建"}
title={t("shareCreateBy", { nick: share.creator.nick })}
className={classes.sideButton}
onClick={(e) => SetShareUserPopover(e.currentTarget)}
style={{ padding: 5 }}