From 47cf9095e5cdf6e1c17a2de825e13955dcf6281e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B1=BC=E9=A6=99ROS?= <87068644+fishros@users.noreply.github.com> Date: Wed, 4 Sep 2024 22:54:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=9B=BD=E5=AE=B6=E5=88=87=E6=8D=A2=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.py | 8 +++++++- tools/base.py | 2 -- tools/translation/translator.py | 8 +++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/install.py b/install.py index 3e06fad..fb54d55 100644 --- a/install.py +++ b/install.py @@ -67,10 +67,16 @@ def main(): importlib.import_module("tools.translation.translator").Linguist() from tools.base import tr + # 使用量统计 CmdTask("wget https://fishros.org.cn/forum/topic/1733 -O /tmp/t1733 -q && rm -rf /tmp/t1733").run() - PrintUtils.print_success(tr.tr("已为您切换语言至当前所在国家语言:")+tr._currentLocale) + PrintUtils.print_success(tr.tr("已为您切换语言至当前所在国家语言:")+tr.lang) + if tr.country != 'CN': + PrintUtils.print_success(tr.tr("检测到当前不在CN,切换服务地址为:https://raw.githubusercontent.com/fishros/install/master/")) + url_prefix = 'https://raw.githubusercontent.com/fishros/install/master/' + + # check base config if not encoding_utf8: print("Your system encoding not support ,will install some packgaes..") diff --git a/tools/base.py b/tools/base.py index 878fcdf..a5c9491 100644 --- a/tools/base.py +++ b/tools/base.py @@ -1427,6 +1427,4 @@ def download_tools(id,tools,url_prefix): url = os.path.join(url_prefix,url) CmdTask("wget {} -O /tmp/fishinstall/tools/{} --no-check-certificate".format(url,url[url.rfind('/')+1:])).run() - - osarch = AptUtils.getArch() \ No newline at end of file diff --git a/tools/translation/translator.py b/tools/translation/translator.py index 9641be9..ca01ce9 100644 --- a/tools/translation/translator.py +++ b/tools/translation/translator.py @@ -10,9 +10,8 @@ from tools.base import CmdTask _suported_languages = ['zh_CN', 'en_US'] -url_prefix = os.environ.get('FISHROS_URL','http://mirror.fishros.com/install')+'/' -lang_url = url_prefix+'tools/translation/assets/{}.py' - +url_prefix = os.environ.get('FISHROS_URL','http://mirror.fishros.com/install') +lang_url = os.path.join(url_prefix,'tools/translation/assets/{}.py') COUNTRY_CODE_MAPPING = { "CN": "zh_CN", @@ -29,6 +28,8 @@ def __init__(self): if self._currentLocale is None: self._currentLocale = locale.getdefaultlocale()[0] # Load the translation file. + self.country = 'CN' + self.lang = self._currentLocale for lang in _suported_languages: CmdTask("wget {} -O /tmp/fishinstall/{} --no-check-certificate".format(lang_url.format(lang),lang_url.format(lang).replace(url_prefix,''))).run() @@ -61,6 +62,7 @@ def getLocalFromIP(self) -> str: with open('/tmp/fishros_check_country.json', 'r') as json_file: data = json.loads(json_file.read()) self.ip_info = data + self.country = data['location']['countryCode'] if data['location']['countryCode'] in COUNTRY_CODE_MAPPING: local_str = COUNTRY_CODE_MAPPING[data['location']['countryCode']] else: