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: