🐛 fix(vscode): Python 的 from 译成「从」
This commit is contained in:
1 parent
83bdfbe9c4
commit
5ce016ba86
3 files changed
+15
-4
No files matched your search
@@ -169,7 +169,7 @@ TypeScript 关键字表(流程 = keyword,声明 = storage):
|
|||||||
|
|
||||||
TypeScript 内置类型:string 字符串、number 数值、boolean 布尔、any 任意、unknown 未知、never 永不、void 无、object 对象、bigint 大整数、symbol 符号。`Promise` 等库类型不翻。
|
TypeScript 内置类型:string 字符串、number 数值、boolean 布尔、any 任意、unknown 未知、never 永不、void 无、object 对象、bigint 大整数、symbol 符号。`Promise` 等库类型不翻。
|
||||||
|
|
||||||
Python 关键字:import 导入、from 来自、as 作为、def 函数、async 异步、await 等待、class 类、return 返回、if 如果、elif 否则如果、else 否则、for 遍历、in(for 头部与推导式里)取自 / (比较里)在、while 当、try 尝试、except 捕获、finally 最终、raise 抛出、with 使用、yield 产出、lambda 匿名函数、pass 跳过、break 跳出、continue 继续、global 全局、nonlocal 非局部、del 删除、assert 断言、not 非、and 与、or 或、is 是、None 空、True 真、False 假、match 匹配、case 情况。
|
Python 关键字:import 导入、from 从、as 作为、def 函数、async 异步、await 等待、class 类、return 返回、if 如果、elif 否则如果、else 否则、for 遍历、in(for 头部与推导式里)取自 / (比较里)在、while 当、try 尝试、except 捕获、finally 最终、raise 抛出、with 使用、yield 产出、lambda 匿名函数、pass 跳过、break 跳出、continue 继续、global 全局、nonlocal 非局部、del 删除、assert 断言、not 非、and 与、or 或、is 是、None 空、True 真、False 假、match 匹配、case 情况。
|
||||||
|
|
||||||
Python 内置类型(仅注解里):str 字符串、int 整数、float 浮点数、bool 布尔、list 列表、dict 字典、set 集合、tuple 元组、bytes 字节串。
|
Python 内置类型(仅注解里):str 字符串、int 整数、float 浮点数、bool 布尔、list 列表、dict 字典、set 集合、tuple 元组、bytes 字节串。
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export const pythonZhTranslator: Translator = createZhTemplateTranslator({
|
|||||||
tokenRole: pythonTokenRole,
|
tokenRole: pythonTokenRole,
|
||||||
keywords: {
|
keywords: {
|
||||||
'import': '导入',
|
'import': '导入',
|
||||||
'from': '来自',
|
'from': '从',
|
||||||
'as': '作为',
|
'as': '作为',
|
||||||
'def': '函数',
|
'def': '函数',
|
||||||
'async': '异步',
|
'async': '异步',
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ describe('python 中文直译', () => {
|
|||||||
expect(texts(map)).toEqual({
|
expect(texts(map)).toEqual({
|
||||||
1: 'Scan a workspace for .env files.',
|
1: 'Scan a workspace for .env files.',
|
||||||
3: '导入 os',
|
3: '导入 os',
|
||||||
4: '来自 pathlib 导入 Path 作为 P',
|
4: '从 pathlib 导入 Path 作为 P',
|
||||||
6: 'MAX_DEPTH = 8',
|
6: 'MAX_DEPTH = 8',
|
||||||
7: 'skipped = 空列表',
|
7: 'skipped = 空列表',
|
||||||
10: '函数 find_env_files(root: 字符串) -> 列表[字符串]',
|
10: '函数 find_env_files(root: 字符串) -> 列表[字符串]',
|
||||||
@@ -152,7 +152,7 @@ describe('python 中文直译', () => {
|
|||||||
24: '使用 open(os.path.join(root, found[0])) 作为 handle',
|
24: '使用 open(os.path.join(root, found[0])) 作为 handle',
|
||||||
25: 'handle.read()',
|
25: 'handle.read()',
|
||||||
26: '捕获 OSError 作为 err',
|
26: '捕获 OSError 作为 err',
|
||||||
27: '抛出 RuntimeError(str(err)) 来自 err',
|
27: '抛出 RuntimeError(str(err)) 从 err',
|
||||||
28: '最终',
|
28: '最终',
|
||||||
29: 'skipped.clear()',
|
29: 'skipped.clear()',
|
||||||
30: '返回 found',
|
30: '返回 found',
|
||||||
@@ -176,4 +176,15 @@ describe('python 中文直译', () => {
|
|||||||
expect(map[1]).toBe('函数 pick(items: 字典[字符串, 整数], list: 集合) -> 元组')
|
expect(map[1]).toBe('函数 pick(items: 字典[字符串, 整数], list: 集合) -> 元组')
|
||||||
expect(map[2]).toBe('返回 [str(k) 遍历 k 取自 items 如果 k 不在 list]')
|
expect(map[2]).toBe('返回 [str(k) 遍历 k 取自 items 如果 k 不在 list]')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('from 在句首译成「从」,yield from 同一个词', async () => {
|
||||||
|
const source = [
|
||||||
|
'from typing import Annotated',
|
||||||
|
'def walk(nodes):',
|
||||||
|
' yield from nodes',
|
||||||
|
].join('\n')
|
||||||
|
const map = texts(await translateAll(py, 'python', pythonZhTranslator, source))
|
||||||
|
expect(map[1]).toBe('从 typing 导入 Annotated')
|
||||||
|
expect(map[3]).toBe('产出 从 nodes')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
Reference in new issue
Block a user