From 08298ed0087ff3387fbb9a9768836795e6570f02 Mon Sep 17 00:00:00 2001 From: kunish Date: Sat, 1 Jul 2023 12:47:08 +0800 Subject: [PATCH] feat(configure-node): add translations --- src/components/NodeModal/HTTPForm.tsx | 14 +++++---- src/components/NodeModal/SSForm.tsx | 10 +++--- src/components/NodeModal/SSRForm.tsx | 20 +++++++----- src/components/NodeModal/Socks5Form.tsx | 12 ++++--- src/components/NodeModal/TrojanForm.tsx | 18 ++++++----- src/components/NodeModal/V2rayForm.tsx | 42 ++++++++++++++----------- src/components/NodeModal/index.tsx | 10 +++--- src/i18n/locales/en.json | 31 ++++++++++++++++++ src/i18n/locales/zh-Hans.json | 31 ++++++++++++++++++ 9 files changed, 134 insertions(+), 54 deletions(-) diff --git a/src/components/NodeModal/HTTPForm.tsx b/src/components/NodeModal/HTTPForm.tsx index 31e6118d..05653bab 100644 --- a/src/components/NodeModal/HTTPForm.tsx +++ b/src/components/NodeModal/HTTPForm.tsx @@ -1,5 +1,6 @@ import { NumberInput, Select, TextInput } from '@mantine/core' import { useForm, zodResolver } from '@mantine/form' +import { useTranslation } from 'react-i18next' import { z } from 'zod' import { FormActions } from '~/components/FormActions' @@ -7,6 +8,7 @@ import { DEFAULT_HTTP_FORM_VALUES, httpSchema } from '~/constants' import { GenerateURLParams, generateURL } from '~/utils' export const HTTPForm = () => { + const { t } = useTranslation() const { onSubmit, getInputProps, reset } = useForm & { protocol: 'http' | 'https' }>({ initialValues: { protocol: 'http', @@ -36,7 +38,7 @@ export const HTTPForm = () => { return (
{ + const { t } = useTranslation() const { values, onSubmit, getInputProps, reset } = useForm>({ initialValues: DEFAULT_SSR_FORM_VALUES, validate: zodResolver(ssrSchema), @@ -25,13 +27,13 @@ export const SSRForm = () => { return ( - + - + - + - + { {...getInputProps('proto')} /> - {values.proto !== 'origin' && } + {values.proto !== 'origin' && ( + + )} { { {...getInputProps('protocol')} /> - + - + - + @@ -100,7 +102,7 @@ export const V2rayForm = () => { {values.protocol === 'vmess' && ( { {values.net === 'tcp' && ( @@ -183,13 +185,17 @@ export const V2rayForm = () => { {(values.net === 'ws' || values.net === 'h2' || values.tls === 'tls' || - (values.net === 'tcp' && values.type === 'http')) && } + (values.net === 'tcp' && values.type === 'http')) && ( + + )} {values.tls === 'tls' && } {values.net === 'ws' || values.net === 'h2' || - (values.net === 'tcp' && values.type === 'http' && )} + (values.net === 'tcp' && values.type === 'http' && ( + + ))} {values.net === 'kcp' && } diff --git a/src/components/NodeModal/index.tsx b/src/components/NodeModal/index.tsx index 34f3717f..b62341f1 100644 --- a/src/components/NodeModal/index.tsx +++ b/src/components/NodeModal/index.tsx @@ -1,4 +1,5 @@ import { MantineProvider, Modal, Stack, Tabs } from '@mantine/core' +import { useTranslation } from 'react-i18next' import { HTTPForm } from './HTTPForm' import { SSForm } from './SSForm' @@ -8,14 +9,13 @@ import { TrojanForm } from './TrojanForm' import { V2rayForm } from './V2rayForm' export const NodeModal = ({ opened, onClose }: { opened: boolean; onClose: () => void }) => { + const { t } = useTranslation() + return ( - + diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index ef5bd26d..1bfb2139 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -39,6 +39,37 @@ "checkTolerance": "Check Tolerance", "collapse": "collapse", "config": "Config", + "configureNode": { + "dtlsObfuscation": "Obfuscated as DTLS1.2 Packets", + "forceTLS": "forcibly TLS on", + "host": "Host", + "hostObfuscation": "Host", + "httpObfuscation": "Obfuscated as HTTP", + "name": "Name", + "network": "Network", + "noObfuscation": "No obfuscation", + "obfs": "Obfuscation", + "obfsParam": "Obfs Param", + "origin": "origin", + "password": "Password", + "path": "Path", + "pathObfuscation": "Path", + "port": "Port", + "protocol": "Protocol", + "protocolParam": "Protocol Param", + "security": "Security", + "seedObfuscation": "Seed", + "servername": "Servername", + "srtpObfuscation": "Obfuscated as Video Calls (SRTP)", + "title": "Configure Node", + "type": "Type", + "username": "Username", + "utpObfuscation": "Obfuscated as Bittorrent (uTP)", + "websocketHost": "WebSocket Host", + "websocketPath": "WebSocket Path", + "wechatVideoObfuscation": "Obfuscated as Wechat Video Calls", + "wireguardObfuscation": "Obfuscated as WireGuard Packets" + }, "confirmModal": { "cancel": "No, It's a mistake", "confirm": "Yes, I'm sure", diff --git a/src/i18n/locales/zh-Hans.json b/src/i18n/locales/zh-Hans.json index 0f57f150..23a57852 100644 --- a/src/i18n/locales/zh-Hans.json +++ b/src/i18n/locales/zh-Hans.json @@ -39,6 +39,37 @@ "checkTolerance": "检测公差", "collapse": "折叠", "config": "配置", + "configureNode": { + "dtlsObfuscation": "伪装为 DTLS1.2 数据包", + "forceTLS": "强制开启 TLS", + "host": "主机地址", + "hostObfuscation": "域名 (host)", + "httpObfuscation": "伪装为 HTTP", + "name": "名字", + "network": "网络", + "noObfuscation": "不伪装", + "obfs": "混淆", + "obfsParam": "混淆参数", + "origin": "原版", + "password": "密码", + "path": "路径", + "pathObfuscation": "路径 (path)", + "port": "端口号", + "protocol": "协议", + "protocolParam": "协议参数", + "security": "安全", + "seedObfuscation": "混淆种子", + "servername": "节点名称", + "srtpObfuscation": "伪装视频通话 (SRTP)", + "title": "配置节点", + "type": "类型", + "username": "用户名", + "utpObfuscation": "伪装为 BT 下载 (uTP)", + "websocketHost": "WebSocket 地址", + "websocketPath": "WebSocket 路径", + "wechatVideoObfuscation": "伪装为微信视频通话", + "wireguardObfuscation": "伪装为 WireGuard 数据包" + }, "confirmModal": { "cancel": "不, 我点错了", "confirm": "是,我确定",