✨ feat(vscode): 代码阅读关键字按语境翻译

This commit is contained in:
cruldra committed 2026-09-25 01:58:07 +08:00
1 parent 72d33032f0
commit d134837c17
5 files changed
+155 -19

No files matched your search

+11 -3
View File
@@ -20,7 +20,7 @@ export const pythonZhTranslator: Translator = createZhTemplateTranslator({
tokenRole: pythonTokenRole,
keywords: {
'import': '导入',
'from': '从',
'from': { zh: '从', byContext: { raise_statement: '源自', yield: '自' } },
'as': '作为',
'def': '函数',
'async': '异步',
@@ -29,9 +29,17 @@ export const pythonZhTranslator: Translator = createZhTemplateTranslator({
'return': '返回',
'if': '如果',
'elif': '否则如果',
'else': '否则',
// 循环的 else 只在没被 break 打断时执行,try 的 else 只在没抛异常时执行
'else': {
zh: '否则',
byContext: {
'for_statement > else_clause': '未中断时',
'while_statement > else_clause': '未中断时',
'try_statement > else_clause': '未出错时',
},
},
'for': '遍历',
'in': { zh: '在', byParent: { for_statement: '取自', for_in_clause: '取自' } },
'in': { zh: '在', byContext: { for_statement: '取自', for_in_clause: '取自' } },
'while': '当',
'try': '尝试',
'except': '捕获',