Skip to content

Commit

Permalink
优化翻译
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Dec 9, 2020
1 parent 08f27e1 commit ffa820a
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 23 deletions.
4 changes: 3 additions & 1 deletion v2ray_util/config_modify/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from v2ray_util import run_type

from ..util_core.v2ray import restart
from ..util_core.utils import readchar, random_email, ColorStr
from ..util_core.group import Vmess, Socks, Mtproto, SS
Expand Down Expand Up @@ -156,7 +158,7 @@ def tfo():
pass
else:
if type(group.node_list[0]) == Mtproto or type(group.node_list[0]) == SS:
print(_("V2ray MTProto/Shadowsocks don't support tcpFastOpen!!!"))
print(_("{} MTProto/Shadowsocks don't support tcpFastOpen!!!".format(run_type.capitalize())))
print("")
return

Expand Down
3 changes: 2 additions & 1 deletion v2ray_util/config_modify/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import random
import string

from v2ray_util import run_type
from ..util_core.v2ray import restart
from ..util_core.writer import StreamWriter, GroupWriter
from ..util_core.selector import GroupSelector, CommonSelector
Expand Down Expand Up @@ -138,7 +139,7 @@ def modify(group=None, sType=None):
choice = int(choice)
if choice > 0 and choice <= len(sm.stream_type):
if sm.stream_type[choice - 1][1] in ("MTProto", "Shadowsocks") and group.tls == 'tls':
print(_("V2ray MTProto/Shadowsocks not support https, close tls success!"))
print(_("{} MTProto/Shadowsocks not support https, close tls success!".format(run_type.capitalize())))
sm.select(sm.stream_type[choice - 1][0])
print(_("modify protocol success"))
if need_restart:
Expand Down
2 changes: 1 addition & 1 deletion v2ray_util/config_modify/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def modify():
pass
else:
if type(group.node_list[0]) == Mtproto or type(group.node_list[0]) == SS:
print(_("V2ray MTProto/Shadowsocks protocol not support https!!!"))
print(_("MTProto/Shadowsocks protocol not support https!!!"))
print("")
return
tm = TLSModifier(group.tag, group.index)
Expand Down
14 changes: 9 additions & 5 deletions v2ray_util/global_setting/stats_ctr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import re
import subprocess

from v2ray_util import run_type
from ..util_core.v2ray import V2ray
from ..util_core.loader import Loader
from ..util_core.writer import GlobalWriter
Expand All @@ -27,6 +28,9 @@ def get_stats(self, meta_info, is_reset=False, is_group=False):
is_reset = "true" if is_reset else "false"

stats_cmd = "cd /usr/bin/v2ray && ./v2ctl api --server=127.0.0.1:{} StatsService.GetStats 'name: \"{}>>>{}>>>traffic>>>{}\" reset: {}'"

if run_type == "xray":
stats_cmd = "cd /usr/bin/xray && ./xray api --server=127.0.0.1:{} StatsService.GetStats 'name: \"{}>>>{}>>>traffic>>>{}\" reset: {}'"
type_tag = ("inbound" if is_group else "user")

stats_real_cmd = stats_cmd.format(str(self.door_port), type_tag, meta_info, "downlink", is_reset)
Expand Down Expand Up @@ -54,9 +58,9 @@ def print_stats(self, horizontal=False):

def manage():

FIND_V2RAY_CRONTAB_CMD = "crontab -l|grep v2ray"
FIND_V2RAY_CRONTAB_CMD = "crontab -l|grep {}".format(run_type)

DEL_UPDATE_TIMER_CMD = "crontab -l|sed '/SHELL=/d;/v2ray/d' > crontab.txt && crontab crontab.txt >/dev/null 2>&1 && rm -f crontab.txt >/dev/null 2>&1"
DEL_UPDATE_TIMER_CMD = "crontab -l|sed '/SHELL=/d;/{}/d' > crontab.txt && crontab crontab.txt >/dev/null 2>&1 && rm -f crontab.txt >/dev/null 2>&1".format(run_type)

while True:
loader = Loader()
Expand All @@ -65,7 +69,7 @@ def manage():

group_list = profile.group_list

print("{}: {}".format(_("V2ray Traffic Statistics Status"), profile.stats.status))
print("{}: {}".format(_("{} Traffic Statistics Status".format(run_type.capitalize())), profile.stats.status))

print("")
print(_("1.open statistics"))
Expand All @@ -78,7 +82,7 @@ def manage():
print("")
print(_("5.reset statistics"))
print("")
print(_("tip: restart v2ray will reset traffic statistics!!!"))
print(_("tip: restart {} will reset traffic statistics!!!".format(run_type)))
print("")

choice = readchar(_("please select: "))
Expand All @@ -90,7 +94,7 @@ def manage():

if choice == "1":
if os.popen(FIND_V2RAY_CRONTAB_CMD).readlines():
rchoice = readchar(_("open traffic statistics will close schedule update v2ray, continue?(y/n): "))
rchoice = readchar(_("open traffic statistics will close schedule update {}, continue?(y/n): ".format(run_type)))
if rchoice == "y" or rchoice == "Y":
#关闭定时更新v2ray服务
os.system(DEL_UPDATE_TIMER_CMD)
Expand Down
12 changes: 7 additions & 5 deletions v2ray_util/global_setting/update_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# -*- coding: utf-8 -*-
import os
import time

from v2ray_util import run_type
from ..util_core.config import Config
from ..util_core.loader import Loader
from ..util_core.utils import ColorStr, readchar
Expand Down Expand Up @@ -33,24 +35,24 @@ def planUpdate():
else:
local_time = 3
os.system('echo "SHELL=/bin/bash" >> crontab.txt && echo "$(crontab -l)" >> crontab.txt')
os.system('echo "0 {} * * * bash <(curl -L -s https://multi.netlify.app/go.sh) | tee -a /root/v2rayUpdate.log && v2ray-util restart" >> crontab.txt'.format(local_time))
os.system('echo "0 {} * * * bash <(curl -L -s https://multi.netlify.app/go.sh) | tee -a /root/{}Update.log && v2ray-util restart" >> crontab.txt'.format(local_time, run_type))
os.system("crontab crontab.txt && rm -f crontab.txt")
restartCron()
print(ColorStr.green(_("success open schedule update task!")))

def manage():
check_result = os.popen("crontab -l|grep v2ray").readlines()
check_result = os.popen("crontab -l|grep {}".format(run_type)).readlines()

status = _("open") if check_result else _("close")

print("{}: {}".format(_("schedule update v2ray task"), status))
print("{}: {}".format(_("schedule update {} task".format(run_type)), status))

print("")
print(_("1.open schedule task"))
print("")
print(_("2.close schedule task"))
print("")
print(_("Tip: open schedule update v2ray at 3:00"))
print(_("Tip: open schedule update {} at 3:00".format(run_type)))

choice = readchar(_("please select: "))

Expand All @@ -61,6 +63,6 @@ def manage():
else:
planUpdate()
elif choice == "2":
os.system("crontab -l|sed '/SHELL=/d;/v2ray/d' > crontab.txt && crontab crontab.txt && rm -f crontab.txt")
os.system("crontab -l|sed '/SHELL=/d;/{}/d' > crontab.txt && crontab crontab.txt && rm -f crontab.txt".format(run_type))
print(ColorStr.green(_("close shedule task success")))
restartCron()
Binary file modified v2ray_util/locale_i18n/zh_CH/LC_MESSAGES/lang.mo
Binary file not shown.
64 changes: 59 additions & 5 deletions v2ray_util/locale_i18n/zh_CH/LC_MESSAGES/lang.po
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ msgstr "修改成功!"
### 通用翻译 end ###

### main.py start ###
msgid "Welcome to v2ray-util"
msgstr "欢迎使用 v2ray-util 管理程序"
msgid "Welcome to v2ray manager"
msgstr "欢迎使用 v2ray 管理程序"

msgid "Welcome to xray manager"
msgstr "欢迎使用 xray 管理程序"

msgid "1.V2ray Manage"
msgstr "1.服务管理"

msgid "1.Xray Manage"
msgstr "1.服务管理"

msgid "2.Group Manage"
msgstr "2.用户管理"

Expand All @@ -54,24 +60,42 @@ msgstr "5.全局功能"
msgid "6.Update V2Ray"
msgstr "6.更新V2Ray"

msgid "6.Update Xray"
msgstr "6.更新Xray"

msgid "7.Generate Client Json"
msgstr "7.生成客户端配置文件"

msgid "start v2ray"
msgstr "启动服务"

msgid "start xray"
msgstr "启动服务"

msgid "stop v2ray"
msgstr "停止服务"

msgid "stop xray"
msgstr "停止服务"

msgid "restart v2ray"
msgstr "重启服务"

msgid "restart xray"
msgstr "重启服务"

msgid "v2ray status"
msgstr "运行状态"

msgid "xray status"
msgstr "运行状态"

msgid "v2ray log"
msgstr "运行日志"

msgid "xray log"
msgstr "运行日志"

msgid "add user"
msgstr "新增用户"

Expand Down Expand Up @@ -120,6 +144,9 @@ msgstr "走CDN(需要域名)"
msgid "V2ray Traffic Statistics"
msgstr "流量统计(v2ray)"

msgid "Xray Traffic Statistics"
msgstr "流量统计(xray)"

msgid "Iptables Traffic Statistics"
msgstr "流量统计(iptables)"

Expand All @@ -129,9 +156,15 @@ msgstr "禁止bittorrent"
msgid "Schedule Update V2ray"
msgstr "定时更新V2ray"

msgid "Clean Log"
msgid "Schedule Update Xray"
msgstr "定时更新Xray"

msgid "Clean V2ray Log"
msgstr "清理v2ray日志"

msgid "Clean Xray Log"
msgstr "清理xray日志"

msgid "Change Language"
msgstr "Switch to English"

Expand Down Expand Up @@ -270,6 +303,9 @@ msgstr "当前无流量数据, 请使用流量片刻再来查看统计!"
msgid "V2ray Traffic Statistics Status"
msgstr "当前V2ray流量统计状态"

msgid "Xray Traffic Statistics Status"
msgstr "当前Xray流量统计状态"

msgid "1.open statistics"
msgstr "1.开启流量统计"

Expand All @@ -288,9 +324,15 @@ msgstr "5.重置流量统计"
msgid "tip: restart v2ray will reset traffic statistics!!!"
msgstr "tip: 重启v2ray会重置流量统计!!!"

msgid "tip: restart xray will reset traffic statistics!!!"
msgstr "tip: 重启xray会重置流量统计!!!"

msgid "open traffic statistics will close schedule update v2ray, continue?(y/n): "
msgstr "开启流量统计会关闭定时更新v2ray服务, 是否继续y/n: "

msgid "open traffic statistics will close schedule update xray, continue?(y/n): "
msgstr "开启流量统计会关闭定时更新xray服务, 是否继续y/n: "

msgid "undo open traffic statistics!!"
msgstr "撤销开启流量统计!!"

Expand Down Expand Up @@ -406,6 +448,9 @@ msgstr "修改tcpFastOpen"
msgid "V2ray MTProto/Shadowsocks don't support tcpFastOpen!!!"
msgstr "V2ray MTProto/Shadowsocks协议不支持配置tcpFastOpen!!!"

msgid "Xray MTProto/Shadowsocks don't support tcpFastOpen!!!"
msgstr "Xray MTProto/Shadowsocks协议不支持配置tcpFastOpen!!!"

msgid "group tcpFastOpen"
msgstr "当前组的tcpFastOpen状态"

Expand Down Expand Up @@ -544,6 +589,9 @@ msgstr "请输入数字!"
msgid "V2ray MTProto/Shadowsocks not support https, close tls success!"
msgstr "V2ray MTProto/Shadowsocks不支持https, 关闭tls成功!"

msgid "Xray MTProto/Shadowsocks not support https, close tls success!"
msgstr "Xray MTProto/Shadowsocks不支持https, 关闭tls成功!"

msgid "modify protocol success"
msgstr "传输模式修改成功!"

Expand Down Expand Up @@ -599,8 +647,8 @@ msgstr "1.开启 TLS"
msgid "2.close TLS"
msgstr "2.关闭 TLS"

msgid "V2ray MTProto/Shadowsocks protocol not support https!!!"
msgstr "V2ray MTProto/Shadowsocks协议不支持配置https!!!"
msgid "MTProto/Shadowsocks protocol not support https!!!"
msgstr "MTProto/Shadowsocks协议不支持配置https!!!"

### tls.py end ###

Expand Down Expand Up @@ -637,6 +685,9 @@ msgstr "关闭"
msgid "schedule update v2ray task"
msgstr "当前定时更新任务状态"

msgid "schedule update xray task"
msgstr "当前定时更新任务状态"

msgid "1.open schedule task"
msgstr "1.开启定时更新任务"

Expand All @@ -646,6 +697,9 @@ msgstr "2.关闭定时更新任务"
msgid "Tip: open schedule update v2ray at 3:00"
msgstr "Tip: 开启定时更新v2ray的更新时间为每天北京时间3:00更新"

msgid "Tip: open schedule update xray at 3:00"
msgstr "Tip: 开启定时更新xray的更新时间为每天北京时间3:00更新"

msgid "have open schedule!"
msgstr "当前定时更新已开启,无需重复操作!"

Expand Down
8 changes: 4 additions & 4 deletions v2ray_util/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def parse_arg():
sys.exit(0)

def service_manage():
show_text = (_("start v2ray"), _("stop v2ray"), _("restart v2ray"), _("v2ray status"), _("v2ray log"))
show_text = (_("start {}".format(run_type)), _("stop {}".format(run_type)), _("restart {}".format(run_type)), _("{} status".format(run_type)), _("{} log".format(run_type)))
print("")
for index, text in enumerate(show_text):
print("{}.{}".format(index + 1, text))
Expand Down Expand Up @@ -202,7 +202,7 @@ def profile_alter():
cdn.modify()

def global_setting():
show_text = (_("V2ray Traffic Statistics"), _("Iptables Traffic Statistics"), _("Ban Bittorrent"), _("Schedule Update V2ray"), _("Clean Log"), _("Change Language"))
show_text = (_("{} Traffic Statistics".format(run_type.capitalize())), _("Iptables Traffic Statistics"), _("Ban Bittorrent"), _("Schedule Update {}".format(run_type.capitalize())), _("Clean {} Log".format(run_type.capitalize())), _("Change Language"))
print("")
for index, text in enumerate(show_text):
print("{}.{}".format(index + 1, text))
Expand Down Expand Up @@ -230,9 +230,9 @@ def menu():
parse_arg()
while True:
print("")
print(ColorStr.cyan(_("Welcome to v2ray-util")))
print(ColorStr.cyan(_("Welcome to {} manager".format(run_type))))
print("")
show_text = (_("1.V2ray Manage"), _("2.Group Manage"), _("3.Modify Config"), _("4.Check Config"), _("5.Global Setting"), _("6.Update V2Ray"), _("7.Generate Client Json"))
show_text = (_("1.{} Manage".format(run_type.capitalize())), _("2.Group Manage"), _("3.Modify Config"), _("4.Check Config"), _("5.Global Setting"), _("6.Update {}".format(run_type.capitalize())), _("7.Generate Client Json"))
for index, text in enumerate(show_text):
if index % 2 == 0:
print('{:<20}'.format(text), end="")
Expand Down
3 changes: 2 additions & 1 deletion v2ray_util/util_core/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import os

from v2ray_util import run_type
from .config import Config
from .utils import ColorStr, get_ip
from .group import SS, Socks, Vmess, Vless, Mtproto, Quic, Group, Dyport, Trojan, Xtls
Expand Down Expand Up @@ -72,7 +73,7 @@ def read_json(self):
self.group_list.append(group)

if len(self.group_list) == 0:
print("v2ray json no streamSettings item, please run {} to recreate v2ray json!".format(ColorStr.cyan("v2ray_util new")))
print("{} json no streamSettings item, please run {} to recreate {} json!".format(run_type, ColorStr.cyan("{} new".format(run_type)), run_type))

del self.config

Expand Down

0 comments on commit ffa820a

Please sign in to comment.