From a64834d3abf0e948e3adfce0f760a011ecb8fdae Mon Sep 17 00:00:00 2001 From: Lazy <2211717435@qq.com> Date: Tue, 31 Oct 2023 16:22:25 +0800 Subject: [PATCH] Feat: add i18n --- frontend/src/hooks/useInstance.ts | 82 +++++++++++++------------------ 1 file changed, 33 insertions(+), 49 deletions(-) diff --git a/frontend/src/hooks/useInstance.ts b/frontend/src/hooks/useInstance.ts index 0a216f2a..74e8e76b 100644 --- a/frontend/src/hooks/useInstance.ts +++ b/frontend/src/hooks/useInstance.ts @@ -145,8 +145,6 @@ export interface InstanceConfigs { redirect: string; type: string; info: string; - author: string; - github: string; category: string[]; conflict?: boolean; check?: boolean; @@ -164,19 +162,17 @@ export function getInstanceConfigByType(type: string) { export const INSTANCE_CONFIGS = [ { // 配置文件显示名 - fileName: "[通用] server.properties", + fileName: t("[通用] server.properties"), // 配置文件对应的实际路径(相对于实例根目录) path: "server.properties", - // 配置文件用于显示界面的组件名(参考 ProcessConfigFile.vue 的 components 属性) + // 配置文件用于显示界面的组件名 redirect: "common/server.properties", // 配置文件解析类型,支持 yml,json,txt,properties type: "properties", // 配置文件中文解释 - info: `Minecraft 服务端极其重要的配置文件,几乎绝大部分常用配置(端口,人数,视距等)均在此文件中进行编辑`, - // 配置文件适配模块作者名 - author: "Unitwk", - // 配置文件 Github 地址(只能放置 Github 地址) - github: "https://github.com/Unitwk", + info: t( + "Minecraft 服务端极其重要的配置文件,几乎绝大部分常用配置(端口,人数,视距等)均在此文件中进行编辑" + ), // 在哪些服务端类型下此配置文件可见 category: [ TYPE_MINECRAFT_SPIGOT, @@ -189,13 +185,11 @@ export const INSTANCE_CONFIGS = [ ] }, { - fileName: "[通用] eula.txt", + fileName: t("[通用] eula.txt"), type: "properties", - info: "软件最终用户协议,此协议必须设置同意,否则无法启用服务端软件", + info: t("软件最终用户协议,此协议必须设置同意,否则无法启用服务端软件"), path: "eula.txt", redirect: "common/eula.txt", - author: "Lazy", - github: "https://github.com/LazyCreeper/", category: [ TYPE_MINECRAFT_SPIGOT, TYPE_MINECRAFT_PAPER, @@ -210,9 +204,9 @@ export const INSTANCE_CONFIGS = [ path: "spigot.yml", redirect: "bukkit/spigot.yml", type: "yml", - info: "Spigot 配置文件,能够进一步的控制服务器的行为和具体参数,一些更为高级的限制都在此配置文件中", - author: "Unitwk", - github: "https://github.com/Unitwk", + info: t( + "Spigot 配置文件,能够进一步的控制服务器的行为和具体参数,一些更为高级的限制都在此配置文件中" + ), category: [ TYPE_MINECRAFT_SPIGOT, TYPE_MINECRAFT_PAPER, @@ -225,9 +219,7 @@ export const INSTANCE_CONFIGS = [ path: "bukkit.yml", redirect: "bukkit/bukkit.yml", type: "yml", - info: "Bukkit 原始配置文件", - author: "AlexanderMC8533 & Lazy", - github: "https://github.com/AlexanderMC8533/", + info: t("Bukkit 原始配置文件"), category: [ TYPE_MINECRAFT_SPIGOT, TYPE_MINECRAFT_PAPER, @@ -238,21 +230,21 @@ export const INSTANCE_CONFIGS = [ { fileName: "[Bungeecord] config.yml", type: "yml", - info: "Bungeecord 群组服务端的重要配置文件,可以进行分布式管理,节点控制等,但此配置文件较为复杂,此处仅供简单的配置和操作", + info: t( + "Bungeecord 群组服务端的重要配置文件,可以进行分布式管理,节点控制等,但此配置文件较为复杂,此处仅供简单的配置和操作" + ), path: "config.yml", redirect: "bungeecord/config.yml", - author: "Lazy", - github: "https://github.com/LazyCreeper/", category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_BUNGEECORD] }, { fileName: "[Velocity] velocity.toml", type: "toml", - info: "Velocity 群组服务端的重要配置文件,可以进行分布式管理,节点控制等,但此配置文件较为复杂,此处仅供简单的配置和操作", + info: t( + "Velocity 群组服务端的重要配置文件,可以进行分布式管理,节点控制等,但此配置文件较为复杂,此处仅供简单的配置和操作" + ), path: "velocity.toml", redirect: "velocity/velocity.toml", - author: "WhitePaper233", - github: "https://github.com/WhitePaper233/", category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_VELOCITY] }, { @@ -260,9 +252,9 @@ export const INSTANCE_CONFIGS = [ path: "server.properties", redirect: "bds/server.properties", type: "properties", - info: `Minecraft Bedrock 服务端极其重要的配置文件,几乎绝大部分常用配置(端口,人数,视距等)均在此文件中进行编辑`, - author: "Lazy", - github: "https://github.com/LazyCreeper", + info: t( + "Minecraft Bedrock 服务端极其重要的配置文件,几乎绝大部分常用配置(端口,人数,视距等)均在此文件中进行编辑" + ), category: [TYPE_MINECRAFT_BDS, TYPE_MINECRAFT_BEDROCK] }, { @@ -270,69 +262,61 @@ export const INSTANCE_CONFIGS = [ path: "mohist.yml", redirect: "mohist/mohist.yml", type: "yml", - info: "mohist.yml 服务端配置文件", - author: "Unitwk", - github: "https://github.com/LazyCreeper", + info: t("mohist.yml 服务端配置文件"), category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_MOHIST] }, { fileName: "[Paper] paper.yml", type: "yml", - info: "PaperSpigot 服务端软件配置文件,能够进一步的配置高级参数以及更具体化的游戏设置,对整体性能有极大的决定效果", + info: t( + "PaperSpigot 服务端软件配置文件,能够进一步的配置高级参数以及更具体化的游戏设置,对整体性能有极大的决定效果" + ), path: "paper.yml", redirect: "paper/paper.yml", - author: "Lazy", - github: "https://github.com/LazyCreeper", category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_PAPER] }, { fileName: "[Paper] paper-global.yml", type: "yml", - info: "PaperSpigot 服务端软件全局配置文件,能够进一步的配置高级参数以及更具体化的游戏设置,对整体性能有极大的决定效果", + info: t( + "PaperSpigot 服务端软件全局配置文件,能够进一步的配置高级参数以及更具体化的游戏设置,对整体性能有极大的决定效果" + ), path: "config/paper-global.yml", redirect: "paper/paper-global.yml", - author: "Lazy", - github: "https://github.com/LazyCreeper", category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_PAPER] }, { fileName: "[Paper] paper-world-defaults.yml", type: "yml", - info: "PaperSpigot 服务端软件世界配置文件,能够进一步在每个世界的基础上进行配置", + info: t("PaperSpigot 服务端软件世界配置文件,能够进一步在每个世界的基础上进行配置"), path: "config/paper-world-defaults.yml", redirect: "paper/paper-world-defaults.yml", - author: "Lazy", - github: "https://github.com/LazyCreeper", category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_PAPER] }, { fileName: "[Geyser] config.yml", type: "yml", - info: "Geyser 服务端软件配置文件,拥有基本的服务器参数设定(如端口,最大玩家数等)并且也可以设定服务端细节参数(区块缓存,线程数等)", + info: t( + "Geyser 服务端软件配置文件,拥有基本的服务器参数设定(如端口,最大玩家数等)并且也可以设定服务端细节参数(区块缓存,线程数等)" + ), path: "config.yml", redirect: "geyser/config.yml", - author: "Lazy", - github: "https://github.com/LazyCreeper", category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_GEYSER] }, { fileName: "[MCDR] config.yml", type: "yml", - info: "MCDReforged 服务端控制工具配置文件", + info: t("MCDReforged 服务端控制工具配置文件"), path: "config.yml", redirect: "mcdr/config.yml", - author: "Huaji_MUR233", - github: "https://github.com/HuajiMUR233", category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_MCDR] }, { fileName: "[MCDR] permission.yml", type: "yml", - info: "MCDReforged 服务端控制工具权限配置文件", + info: t("MCDReforged 服务端控制工具权限配置文件"), path: "permission.yml", redirect: "mcdr/permission.yml", - author: "Huaji_MUR233", - github: "https://github.com/HuajiMUR233", category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_MCDR] } ];