本项目通过将 rogeraabbccdd/GitKraken-zh-tw 翻译包内的繁体中文文件转化为简体中文而成,采用了 Python3.9
作为转换工具并利用 Github Actions
进行每日自动构建。
strings.json
对应于本项目目录下的 strings.json
(并不在 Release发布页)#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
import pprint
import zhconv
import codecs
import sys
class Translation():
def read_json(self):
return json.load(codecs.open(sys.argv[1],'r',encoding="utf-8"))
t = Translation()
dict = t.read_json()
#pprint.pprint(dict)
dict["languageOption"]["label"] ="简体中文"
dict["languageOption"]["value"] = 'zh-CN'
menuStrings = dict["menuStrings"]
for key,value in menuStrings.items():
menuStrings[key] = zhconv.convert(value, 'zh-cn')
strings = dict["strings"]
for key,value in strings.items():
strings[key] = zhconv.convert(value, 'zh-cn')
output = json.dumps(dict, indent=2, ensure_ascii=False)
f = codecs.open("./strings.json", "w", encoding="utf8")
f.write(output)
name: StartTranslations
# 每天定时操作,仓库上传时也进行构建
on:
push:
schedule:
- cron: '0 12 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python2.9
uses: actions/setup-python@v3
with:
python-version: 3.9.1
- name: requirements
run: |
python -m pip install --upgrade pip
pip3 install zhconv
- name: Sync gitkraken-zh-tw
run: |
git --version
git clone https://github.com/rogeraabbccdd/GitKraken-zh-tw.git
- name: start translate
run: |
python ./tw2cn.py ./GitKraken-zh-tw/strings.json
rm -rf GitKraken-zh-tw
- name: commit
run: |
git config --global user.email 849919718@qq.com
git config --global user.name easterNday
git add .
git commit -m "Update" -a
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}