diff --git a/public/locales/en-US/dashboard.json b/public/locales/en-US/dashboard.json index 9831418..ff11893 100644 --- a/public/locales/en-US/dashboard.json +++ b/public/locales/en-US/dashboard.json @@ -551,7 +551,7 @@ "disabled": "Disabled", "online": "Online", "offline": "Offline", - "addNewNode": "Add new node", + "addNewNode": "New node", "refresh": "Refresh", "enableNode": "Enable node", "disableNode": "Disable node", @@ -609,5 +609,52 @@ "nodeSavedNow": "Node saved successfully.", "editNode": "Edit node", "addNode": "Add node" + }, + "group": { + "#": "#", + "name": "Name", + "type": "Storage policy", + "count": "Child users", + "size": "Storage quota", + "action": "Actions", + "deleted": "Group deleted.", + "new": "New group", + "aria2FormatError": "Aria2 options format error.", + "atLeastOnePolicy": "At least one storage policy is required.", + "added": "Group added successfully.", + "saved": "Group saved successfully.", + "editGroup": "Edit {{group}}", + "nameOfGroup": "Name", + "nameOfGroupDes": "Name of the group.", + "storagePolicy": "Storage policy", + "storageDes": "Select the storage policy that this group use.", + "initialStorageQuota": "Initial storage quota", + "initialStorageQuotaDes": "Max storage can used by single user under this group.", + "downloadSpeedLimit": "Max download speed", + "downloadSpeedLimitDes": "Fill in 0 to indicate no limit. When the restriction is turned on, the maximum download speed will be limited when users under this user group download all files under the storage policy that supports the speed limit.", + "bathSourceLinkLimit": "Max size of batch source links", + "bathSourceLinkLimitDes": "For the files under the supported storage policy, the maximum number of files allowed for users to obtain source links in a single batch, fill in 0 means no batch generation of source links is allowed.", + "allowCreateShareLink": "Share files", + "allowCreateShareLinkDes": "If disabled, users cannot create sharing links.", + "allowDownloadShare": "Download shared files", + "allowDownloadShareDes": "If disabled, user cannot download shared files.", + "allowWabDAV": "WebDAV", + "allowWabDAVDes": "If disabled, users cannot connect to the storage via the WebDAV protocol", + "disableMultipleDownload": "Disable multiple download requests", + "disableMultipleDownloadDes": "Valid only for local storage policies. When disabled, users cannot use the multi-threaded download tool.", + "allowRemoteDownload": "Remote download", + "allowRemoteDownloadDes": "Whether to allow users to create remote download tasks", + "aria2Options": "Aria2 job options", + "aria2OptionsDes": "The additional parameters that this user group carries when creating remote download tasks. Options are written in JSON encoded format, you can also write these settings in the Aria2 configuration file, see the official documentation for available parameters.", + "aria2BatchSize": "Max size of batch Aria2 tasks", + "aria2BatchSizeDes": "The number of simultaneous remote download tasks allowed for the user, fill in 0 or leave blank to indicate no limit.", + "serverSideBatchDownload": "Serverside batch download", + "serverSideBatchDownloadDes": "Whether to allow users to select multiple files to use the server-side relay batch download, after disabled, users can still use the pure browser based batch download feature.", + "compressTask": "Compression/Decompression tasks", + "compressTaskDes": "Whether allow the user to create the compression/decompression task", + "compressSize": "Maximum file size to be compressed", + "compressSizeDes": "The maximum total file size of compression jobs that can be created by the user, fill in 0 to indicate no limit.", + "decompressSize": "Maximum file size to be decompressed", + "decompressSizeDes": "The maximum total file size of decompression jobs that can be created by the user, fill in 0 to indicate no limit.", } } \ No newline at end of file diff --git a/public/locales/zh-CN/dashboard.json b/public/locales/zh-CN/dashboard.json index 9f592bb..cce330e 100644 --- a/public/locales/zh-CN/dashboard.json +++ b/public/locales/zh-CN/dashboard.json @@ -599,7 +599,7 @@ "loadBalancerRankDes": "为此节点指定负载均衡权重,数值为整数。某些负载均衡策略会根据此数值加权选择节点", "loadBalancerRank": "负载均衡权重", "nodeSaved": "节点已保存!", - "nodeSavedFutureAction": "如果您添加了新节点,还需要在节点列表手动启动节点才能正常使用。" + "nodeSavedFutureAction": "如果您添加了新节点,还需要在节点列表手动启动节点才能正常使用。", "backToNodeList": "返回节点列表", "communication": "通信配置", "otherSettings": "杂项信息", @@ -608,5 +608,52 @@ "nodeSavedNow": "节点已保存", "editNode": "编辑节点", "addNode": "添加节点" + }, + "group": { + "#": "#", + "name": "名称", + "type": "存储策略", + "count": "下属用户数", + "size": "最大容量", + "action": "操作", + "deleted": "用户组已删除", + "new": "新建用户组", + "aria2FormatError": "Aria2 设置项格式错误", + "atLeastOnePolicy": "至少要为用户组选择一个存储策略", + "added": "用户组已添加", + "saved": "用户组已保存", + "editGroup": "编辑 {{group}}", + "nameOfGroup": "用户组名", + "nameOfGroupDes": "用户组的名称", + "storagePolicy": "存储策略", + "storageDes": "指定用户组的存储策略。", + "initialStorageQuota": "初始容量", + "initialStorageQuotaDes": "用户组下的用户初始可用最大容量", + "downloadSpeedLimit": "下载限速", + "downloadSpeedLimitDes": "填写为 0 表示不限制。开启限制后,此用户组下的用户下载所有支持限速的存储策略下的文件时,下载最大速度会被限制。", + "bathSourceLinkLimit": "批量生成外链数量限制", + "bathSourceLinkLimitDes": "对于支持的存储策略下的文件,允许用户单次批量获取外链的最大文件数量,填写为 0 表示不允许批量生成外链。", + "allowCreateShareLink": "允许创建分享", + "allowCreateShareLinkDes": "关闭后,用户无法创建分享链接", + "allowDownloadShare": "允许下载分享", + "allowDownloadShareDes": "关闭后,用户无法下载别人创建的文件分享", + "allowWabDAV": "WebDAV", + "allowWabDAVDes": "关闭后,用户无法通过 WebDAV 协议连接至网盘", + "disableMultipleDownload": "禁止多次下载请求", + "disableMultipleDownloadDes": "只针对本机存储策略有效。开启后,用户无法使用多线程下载工具。", + "allowRemoteDownload": "离线下载", + "allowRemoteDownloadDes": "是否允许用户创建离线下载任务", + "aria2Options": "Aria2 任务参数", + "aria2OptionsDes": "此用户组创建离线下载任务时额外携带的参数,以 JSON 编码后的格式书写,您可也可以将这些设置写在 Aria2 配置文件里,可用参数请查阅官方文档", + "aria2BatchSize": "Aria2 批量下载最大数量", + "aria2BatchSizeDes": "允许用户同时进行的离线下载任务数量,填写为 0 或留空表示不限制。", + "serverSideBatchDownload": "服务端打包下载", + "serverSideBatchDownloadDes": "是否允许用户多选文件使用服务端中转打包下载,关闭后,用户仍然可以使用纯 Web 端打包下载功能。", + "compressTask": "压缩/解压缩 任务", + "compressTaskDes": "是否用户创建 压缩/解压缩 任务", + "compressSize": "待压缩文件最大大小", + "compressSizeDes": "用户可创建的压缩任务的文件最大总大小,填写为 0 表示不限制", + "decompressSize": "待解压文件最大大小", + "decompressSizeDes": "用户可创建的解压缩任务的文件最大总大小,填写为 0 表示不限制", } } \ No newline at end of file diff --git a/src/component/Admin/Group/EditGroup.js b/src/component/Admin/Group/EditGroup.js index eaf5fa6..46074cc 100644 --- a/src/component/Admin/Group/EditGroup.js +++ b/src/component/Admin/Group/EditGroup.js @@ -4,8 +4,10 @@ import API from "../../../middleware/Api"; import { useDispatch } from "react-redux"; import GroupForm from "./GroupForm"; import { toggleSnackbar } from "../../../redux/explorer"; +import { useTranslation } from "react-i18next"; export default function EditGroupPreload() { + const { t } = useTranslation("dashboard", { keyPrefix: "group" }); const [group, setGroup] = useState({}); const { id } = useParams(); @@ -72,7 +74,7 @@ export default function EditGroupPreload() { ToggleSnackbar( "top", "right", - "Aria2 设置项格式错误", + t("aria2FormatError"), "warning" ); return; diff --git a/src/component/Admin/Group/Group.js b/src/component/Admin/Group/Group.js index 0794532..9188639 100644 --- a/src/component/Admin/Group/Group.js +++ b/src/component/Admin/Group/Group.js @@ -17,6 +17,7 @@ import { useHistory, useLocation } from "react-router"; import { toggleSnackbar } from "../../../redux/explorer"; import API from "../../../middleware/Api"; import { sizeToString } from "../../../utils"; +import { useTranslation } from "react-i18next"; const useStyles = makeStyles((theme) => ({ root: { @@ -42,24 +43,21 @@ const useStyles = makeStyles((theme) => ({ })); const columns = [ - { id: "#", label: "#", minWidth: 50 }, - { id: "name", label: "名称", minWidth: 170 }, + { id: "#", minWidth: 50 }, + { id: "name", minWidth: 170 }, { id: "type", label: "存储策略", minWidth: 170 }, { id: "count", - label: "下属用户数", minWidth: 50, align: "right", }, { id: "size", - label: "最大容量", minWidth: 100, align: "right", }, { id: "action", - label: "操作", minWidth: 170, align: "right", }, @@ -70,6 +68,8 @@ function useQuery() { } export default function Group() { + const { t } = useTranslation("dashboard", { keyPrefix: "group" }); + const { t: tDashboard } = useTranslation("dashboard"); const classes = useStyles(); const [groups, setGroups] = useState([]); const [statics, setStatics] = useState([]); @@ -78,9 +78,7 @@ export default function Group() { const [total, setTotal] = useState(0); const [policies, setPolicies] = React.useState({}); - const location = useLocation(); const history = useHistory(); - const query = useQuery(); const dispatch = useDispatch(); const ToggleSnackbar = useCallback( @@ -127,7 +125,7 @@ export default function Group() { API.delete("/admin/group/" + id) .then(() => { loadList(); - ToggleSnackbar("top", "right", "用户组已删除", "success"); + ToggleSnackbar("top", "right", t("deleted"), "success"); }) .catch((error) => { ToggleSnackbar("top", "right", error.message, "error"); @@ -142,7 +140,7 @@ export default function Group() { onClick={() => history.push("/admin/group/add")} variant={"contained"} > - 新建用户组 + {t("new")}
@@ -166,7 +164,7 @@ export default function Group() { align={column.align} style={{ minWidth: column.minWidth }} > - {column.label} + {t(column.id)} ))} @@ -201,7 +199,9 @@ export default function Group() { sizeToString(row.MaxStorage)} - + history.push( @@ -214,7 +214,9 @@ export default function Group() { - + deletePolicy(row.ID) diff --git a/src/component/Admin/Group/GroupForm.js b/src/component/Admin/Group/GroupForm.js index fc0e4f2..34710ee 100644 --- a/src/component/Admin/Group/GroupForm.js +++ b/src/component/Admin/Group/GroupForm.js @@ -16,6 +16,7 @@ import { useHistory } from "react-router"; import { toggleSnackbar } from "../../../redux/explorer"; import API from "../../../middleware/Api"; import SizeInput from "../Common/SizeInput"; +import { useTranslation } from "react-i18next"; const useStyles = makeStyles((theme) => ({ root: { @@ -46,6 +47,8 @@ const useStyles = makeStyles((theme) => ({ // } export default function GroupForm(props) { + const { t } = useTranslation("dashboard", { keyPrefix: "group" }); + const { t: tDashboard } = useTranslation("dashboard"); const classes = useStyles(); const [loading, setLoading] = useState(false); const [group, setGroup] = useState( @@ -183,7 +186,7 @@ export default function GroupForm(props) { groupCopy.OptionsSerialized.aria2_options ); } catch (e) { - ToggleSnackbar("top", "right", "Aria2 设置项格式错误", "warning"); + ToggleSnackbar("top", "right", t("aria2FormatError"), "warning"); return; } @@ -196,7 +199,7 @@ export default function GroupForm(props) { ToggleSnackbar( "top", "right", - "用户组已" + (props.group ? "保存" : "添加"), + props.group ? t("saved") : t("added"), "success" ); }) @@ -213,8 +216,8 @@ export default function GroupForm(props) {
- {group.ID === 0 && "新建用户组"} - {group.ID !== 0 && "编辑 " + group.Name} + {group.ID === 0 && t("new")} + {group.ID !== 0 && t("editGroup", { name: group.Name })}
@@ -223,7 +226,7 @@ export default function GroupForm(props) {
- 用户组名 + {t("nameOfGroup")} - 用户组的名称 + {t("nameOfGroupDes")}
@@ -239,7 +242,7 @@ export default function GroupForm(props) {
- 存储策略 + {t("storagePolicy")} - 对于支持的存储策略下的文件,允许用户单次批量获取外链的最大文件数量,填写为 - 0 或空表示不允许批量生成外链。 + {t("bathSourceLinkLimitDes")}
@@ -350,10 +351,10 @@ export default function GroupForm(props) { )} /> } - label="允许创建分享" + label={t("allowCreateShareLink")} /> - 关闭后,用户无法创建分享链接 + {t("allowCreateShareLinkDes")}
@@ -373,10 +374,10 @@ export default function GroupForm(props) { )} /> } - label="允许下载分享" + label={t("allowDownloadShare")} /> - 关闭后,用户无法下载别人创建的文件分享 + {t("allowDownloadShareDes")}
@@ -396,11 +397,10 @@ export default function GroupForm(props) { )} /> } - label="WebDAV" + label={t("allowWabDAV")} /> - 关闭后,用户无法通过 WebDAV - 协议连接至网盘 + {t("allowWabDAVDes")} @@ -421,10 +421,10 @@ export default function GroupForm(props) { )} /> } - label="禁止多次下载请求" + label={t("disableMultipleDownload")} /> - 只针对本机存储策略有效。开启后,用户无法使用多线程下载工具。 + {t("disableMultipleDownloadDes")} @@ -444,10 +444,10 @@ export default function GroupForm(props) { )} /> } - label="离线下载" + label={t("allowRemoteDownload")} /> - 是否允许用户创建离线下载任务 + {t("allowRemoteDownloadDes")} @@ -457,7 +457,7 @@ export default function GroupForm(props) {
- Aria2 任务参数 + {t("aria2Options")} - 此用户组创建离线下载任务时额外携带的参数,以 - JSON - 编码后的格式书写,您可也可以将这些设置写在 - Aria2 配置文件里,可用参数请查阅官方文档 + {t("aria2OptionsDes")}
- Aria2 批量下载最大数量 + {t("aria2BatchSize")} - 允许用户单次批量创建的离线下载链接的最大数量 + {t("aria2BatchSizeDes")}
@@ -517,11 +514,10 @@ export default function GroupForm(props) { )} /> } - label="服务端打包下载" + label={t("serverSideBatchDownload")} /> - 是否允许用户多选文件使用服务端中转打包下载,关闭后,用户仍然可以使用纯 - Web 端打包下载功能。 + {t("serverSideBatchDownloadDes")} @@ -541,10 +537,10 @@ export default function GroupForm(props) { )} /> } - label="压缩/解压缩 任务" + label={t("compressTask")} /> - 是否用户创建 压缩/解压缩 任务 + {t("compressTaskDes")} @@ -565,12 +561,11 @@ export default function GroupForm(props) { )} min={0} max={9223372036854775807} - label={"待压缩文件最大大小"} + label={t("compressSize")} /> - 用户可创建的压缩任务的文件最大总大小,填写为 - 0 表示不限制 + {t("compressSizeDes")} @@ -586,12 +581,11 @@ export default function GroupForm(props) { )} min={0} max={9223372036854775807} - label={"待解压文件最大大小"} + label={t("decompressSize")} /> - 用户可创建的解压缩任务的文件最大总大小,填写为 - 0 表示不限制 + {t("decompressSizeDes")} @@ -604,7 +598,7 @@ export default function GroupForm(props) { variant={"contained"} color={"primary"} > - 保存 + {tDashboard("settings.save")}