(sitepath)
return
执行汉化
执行汉化
执行汉化
def chinesize(sitepath):
    '''执行汉化'''
    # base.py add zh_CN
    configpath = sitepath + '{0}spyder{1}config{2}base.py'.format(FLAG,FLAG,FLAG)
    print(configpath)
    newpath = sitepath + '{0}base.py'.format(FLAG)
    # 根据操作系统（Win和linux）、python2个大版本分别读取配置信息
    # 2020年之后就好了
    if thissys == 'Windows':
        if pyver > 2.7:
            newf = open(newpath, 'w', encoding='utf-8')
            with open(configpath, 'r',encoding='utf-8') as f:
                lines = f.readlines()
        else:
            import io
            newf = io.open(newpath, 'w', encoding='utf-8')
            with io.open(configpath, 'r',encoding='utf-8') as f:
                lines = f.readlines()
    
        islanguage = 0
        for i in range(len(lines)):
            line = lines[i]
            newf.writelines(line)
            if "LANGUAGE_CODES = {'en': u'English'," in line:
                islanguage = 1
                mystr = "                  'zh_CN': u'简体中文',\n" if pyver >2.7 else u"                  'zh_CN': u'简体中文',\n"
                
                newf.writelines(mystr)
    
    else:
        newf = open(newpath, 'w')
        with open(configpath, 'r') as f:
            lines = f.readlines()
            islanguage = 0
        for i in range(len(lines)):
            line = lines[i]
            newf.writelines(line)
            if "LANGUAGE_CODES = {'en': u'English'," in line:
                #print(line)
                islanguage = 1
                mystr = "                  'zh_CN': u'简体中文',\n"
                newf.writelines(mystr)
    newf.close()

    # rename old base.py
    if os.path.exists(sitepath + r'{0}spyder{1}config{2}base_bak.py'.format(FLAG, FLAG, FLAG)):
        os.remove(sitepath + r'{0}spyder{1}config{2}base_bak.py'.format(FLAG, FLAG, FLAG))
    os.rename(configpath,sitepath + r'{0}spyder{1}config{2}base_bak.py'.format(FLAG, FLAG, FLAG)) 
    # remove new base.py
    shutil.move(newpath,configpath) 
    mystr = u'中文语言包安装完毕，重启后配置语言选项即可。\n\n 按ENTER键开始子模块汉化'
    pyinput(mystr)
    return
def chinesize ( sitepath ) : # base.py add zh_CN configpath = sitepath + '{0}spyder{1}config{2}base.py' . format ( FLAG , FLAG , FLAG ) print ( configpath ) newpath = sitepath + '{0}base.py' . format ( FLAG ) # 根据操作系统（Win和linux）、python2个大版本分别读取配置信息 # 2020年之后就好了 if thissys == 'Windows' : if pyver > 2.7 : newf = open ( newpath , 'w' , encoding = 'utf-8' ) with open ( configpath , 'r' , encoding = 'utf-8' ) as f : lines = f . readlines ( ) else : import io newf = io . open ( newpath , 'w' , encoding = 'utf-8' ) with io . open ( configpath , 'r' , encoding = 'utf-8' ) as f : lines = f . readlines ( ) islanguage = 0 for i in range ( len ( lines ) ) : line = lines [ i ] newf . writelines ( line ) if "LANGUAGE_CODES = {'en': u'English'," in line : islanguage = 1 mystr = "                  'zh_CN': u'简体中文',\n" if pyve  > .7 el e  u"             'zh_CN': u'简体中文',\n" newf . writelines ( mystr ) else : newf = open ( newpath , 'w' ) with open ( configpath , 'r' ) as f : lines = f . readlines ( ) islanguage = 0 for i in range ( len ( lines ) ) : line = lines [ i ] newf . writelines ( line ) if "LANGUAGE_CODES = {'en': u'English'," in line : #print(line) islanguage = 1 mystr = "                  'zh_CN': u'简体中文',\n" newf . writelines ( mystr ) newf . close ( ) # rename old base.py if os . path . exists ( sitepath + r'{0}spyder{1}config{2}base_bak.py' . format ( FLAG , FLAG , FLAG ) ) : os . remove ( sitepath + r'{0}spyder{1}config{2}base_bak.py' . format ( FLAG , FLAG , FLAG ) ) os . rename ( configpath , sitepath + r'{0}spyder{1}config{2}base_bak.py' . format ( FLAG , FLAG , FLAG ) ) # remove new base.py shutil . move ( newpath , configpath ) mystr = u'中文语言包安装完毕，重启后配置语言选项即可。\n\n 按ENTER键开始子模块汉化' pyinput ( mystr ) return