-
Notifications
You must be signed in to change notification settings - Fork 15
新增一处翻译文本
muzili edited this page Nov 17, 2024
·
1 revision
如图: 首先确定要翻译的文本 Open options
以3.4.9版本为例
位置:C:\Users\USERNAME\AppData\Local\GitHubDesktop\app-3.4.9\resources\app\renderer.js
- 全局搜索:
"Open options"
- 发现找到了三处, 且都是key为
cancelButtonText
时的值 - 根据图片中文本的位置来看,确实是取消按钮,所以可以将 cancelButtonText 也包括进去进行匹配
- 所以匹配的内容为:
cancelButtonText:"Open options"
- 将此项放入json文件的
renderer_dev
对象中,并对引号进行转义: - :
cancelButtonText:\"Open options\"
, 编写替换后的文本为cancelButtonText:\"打开选项\"
- 将此文本放入 renderer_dev 数组的第一项中(直接在空白的
["\"\"","\"\""]
中填入 不需要新增)
"renderer_dev": [
["cancelButtonText:\"Open options\"","cancelButtonText:\"打开选项\""],
["\"\"","\"\""],
["\"\"","\"\""],
["\"\"","\"\""],
["\"\"","\"\""],
["\"\"","\"\""],
["\"\"","\"\""],
["\"\"","\"\""],
["\"\"","\"\""],
["\"\"","\"\""],
["\"\"","\"\""],
["\"\"","\"\""]
]
-
然后运行替换程序:
GitHubDesktop2Chinese.exe -j "Your JSON File Path /localization.json" dev --devreplace
-
结果无报错。
-
重启Github Desktop可以看到翻译完成
-
将
["cancelButtonText:\"Open options\"","cancelButtonText:\"打开选项\""],
一行剪切,粘贴到上面renderer对象的其他翻译结尾,["\"\"","\"\""]
的上一行
["title:\"Error\"","title:\"错误\""],
["The file is empty","这个文件是空的"],
["cancelButtonText:\"Open options\"","\"\""],
["\"\"","\"\""]
],
"renderer_dev": [
["\"\"","\"\""],
- GitHub 推送至仓库,提交PR 即可。
- 如果运行后发现程序打不开了, 说明你把js代码也给替换了,导致代码出错了,去renderer.js目录 有个renderer.js.bak文件, 将这个文件重命名一份替换renderer.js就可以了