在线代码离线翻译Chrome插件一马v0.0.8 2018-10-31
生活随笔
收集整理的這篇文章主要介紹了
在线代码离线翻译Chrome插件一马v0.0.8 2018-10-31
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
續前文: Chrome插件實現GitHub代碼離線翻譯v0.0.4
添加了對"碼云"在線代碼的翻譯支持, 因此改名暫為"一馬". 在此貼中調研了常用的在線代碼網站: 各位都在什么源碼站上在線看代碼? - V2EX, 暫未發現其他.
注: 此插件調用瀏覽器插件-離線英漢詞典 0.0.7進行查詞, 因此也不依賴任何在線翻譯服務, 不存在API調用限制.
改進功能:
- 支持"碼云"代碼翻譯
- 添加 C/PHP 關鍵詞的翻譯
- 刪除釋義中的括號內內容
"碼云"的代碼段與GitHub的HTML結構略有不同, 暫時分別處理如下:
大幅增加了通用關鍵詞的手工翻譯, 以覆蓋盡可能多的編程語言:
// TODO: 并非所有編程語言都有. 會影響命名翻譯. var 通用關鍵詞 = {"abstract": "抽象","and": "且","as": "as","assert": "斷言","break": "跳出","boolean": "布爾","byte": "字節","char": "字節","const": "const","case": "分支","class": "類別","catch": "接住","continue": "繼續","default": "默認","do": "執行","double": "雙浮點","else": "否則","enum": "枚舉","extends": "擴展","extern": "外部","false": "假","final": "最終","finally": "善后","float": "單浮點","for": "對于","function": "函數","global": "全局","goto": "goto","if": "如果","implements": "實現","import": "導入","in": "在","include": "包括","instanceof": "為實例","int": "整數","interface": "接口","is": "為","long": "長整數","native": "native","new": "新","null": "空","or": "或","package": "包","private": "私有","protected": "保護","public": "公有","return": "返回","short": "短整數","signed": "有符號","sizeof": "大小","static": "靜態","struct": "結構","super": "父類","switch": "岔","synchronized": "同步","this": "本身","throw": "拋出","throws": "會拋出","transient": "transient","true": "真","try": "嘗試","typedef": "類型定義","union": "聯合","unsigned": "無符號","void": "無值","volatile": "volatile","while": "每當","with": "with","yield": "產出" }var 專用關鍵詞 = {// https://msdn.microsoft.com/en-us/library/befeaky0.aspx"c": {"auto": "auto","register": "register"},// http://php.net/manual/en/reserved.keywords.php"php": {// array()"callable": "可調用","clone": "克隆","const": "const","declare": "聲明",// die()"echo": "回響","elseif": "否則如果",// empty()"enddeclare": "結束聲明","endfor": "結束for","endforeach": "結束foreach","endif": "結束if","endswitch": "結束switch","endwhile": "結束while",// eval()// exit()"foreach": "對每個","implements": "實現","include_once": "包括_單次","instanceof": "為實例","insteadof": "insteadof","interface": "接口",// isset()// list()"namespace": "命名空間","print": "打印","require": "需要","require": "需要_單次","trait": "trait",// unset()"use": "use","var": "var","xor": "異或"},"javascript": {"arguments": "參數","await": "等待","debugger": "調試器","delete": "刪除","eval": "eval","export": "導出","let": "讓","typeof": "為類型","var": "變量"},/*參考 http://zetcode.com/lang/python/keywords/import keywordprint("Python keywords: ", keyword.kwlist)*/"python": {"False": "假","None": "空","True": "真","def": "定義","del": "刪除","elif": "否則如果","except": "except","from": "從","lambda": "lambda","nonlocal": "nonlocal","not": "不","pass": "輪空","raise": "拋出",},// 參考 https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html"java": {"strictfp": "strictfp"} }Chrome插件商店
下個版本打算改進的(11/02/2018: 在0.0.11版中已基本完成):
-
讓用戶可以選擇是否中文化關鍵詞 · Issue #3 · program-in-chinese/webextension_github_code_translator
-
常用命名/縮寫的手工翻譯 · Issue #17 · program-in-chinese/webextension_github_code_translator
-
復數詞匯取原詞釋義 · Issue #12 · program-in-chinese/webextension_github_code_translator: 也許還需要詞頻數據.
總結
以上是生活随笔為你收集整理的在线代码离线翻译Chrome插件一马v0.0.8 2018-10-31的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 智能仪器及智能仪表设计的新突破--将实时
- 下一篇: js实现京东秒杀