MySQLWorkbench汉化(Python,google翻译)

注意是MAC版本的

汉化主要是翻译main_menu.xml文件中相对应的英文
主要用到Python爬虫去google翻译

替换:
/应用程序/MySQLWorkbench/Contents/Resources/data/main_menu.xml
(注:右键显示包文件)

需求:
1.Python遍历文件找到对应英文内容,
2.去google翻译,
3.替换内容


Tkk.js(文件是从git上找的,忘记出处了)

//Tkk.js 负责计算 tk值
function b(a, b) {
  for (var d = 0; d < b.length - 2; d += 3) {
      var c = b.charAt(d + 2),
          c = "a" <= c ? c.charCodeAt(0) - 87 : Number(c),
          c = "+" == b.charAt(d + 1) ? a >>> c : a << c;
      a = "+" == b.charAt(d) ? a + c & 4294967295 : a ^ c
  }
  return a
}

function tk(a,TKK) {
    for (var e = TKK.split("."), h = Number(e[0]) || 0, g = [], d = 0, f = 0; f < a.length; f++) {
        var c = a.charCodeAt(f);
        128 > c ? g[d++] = c : (2048 > c ? g[d++] = c >> 6 | 192 : (55296 == (c & 64512) && f + 1 < a.length && 56320 == (a.charCodeAt(f + 1) & 64512) ? (c = 65536 + ((c & 1023) << 10) + (a.charCodeAt(++f) & 1023), g[d++] = c >> 18 | 240, g[d++] = c >> 12 & 63 | 128) : g[d++] = c >> 12 | 224, g[d++] = c >> 6 & 63 | 128), g[d++] = c & 63 | 128)
    }
    a = h;
    for (d = 0; d < g.length; d++) a += g[d], a = b(a, "+-a^+6");
    a = b(a, "+-3^+b+-f");
    a ^= Number(e[1]) || 0;
    0 > a && (a = (a & 2147483647) + 2147483648);
    a %= 1E6;
    return a.toString() + "." + (a ^ h)
}

Python代码

import os
import requests
import json
import execjs
import urllib
import re
from lxml import etree


def start(file):

    old_file = '/Users/***/Desktop/my/main_menu.xml'

    session = requests.session()

    with open(old_file, "r", encoding="utf-8") as f1,open("%s.bak" % file, "w", encoding="utf-8") as f2:
        for line in f1:
            a = 'caption">'
            if a in line:
                print(line)
                q = line.index(a)
                w = line.index('

MySQLWorkbench汉化-version 8.0.13
提取码: 39hx

你可能感兴趣的:(MySQLWorkbench汉化(Python,google翻译))