Skip to content

Commit 371485e

Browse files
committed
translation
1 parent fee4561 commit 371485e

156 files changed

Lines changed: 606 additions & 607 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/core/function/typed.js

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ export const createTyped = /* #__PURE__ */ factory('typed', dependencies, functi
178178

179179
// note: conversion from number to BigNumber can fail if x has >15 digits
180180
if (digits(x) > 15) {
181-
throw new TypeError('Cannot implicitly convert a number with >15 significant digits to BigNumber ' +
182-
'(value: ' + x + '). ' +
183-
'Use function bignumber(x) to convert to BigNumber.')
181+
throw new TypeError('无法隐式将一个>15位的浮点数转换为大数' +
182+
'(值: ' + x + '). ' +
183+
'使用函数 bignumber(x) 转换为大数.')
184184
}
185185
return new BigNumber(x)
186186
}
@@ -239,8 +239,8 @@ export const createTyped = /* #__PURE__ */ factory('typed', dependencies, functi
239239
from: 'Fraction',
240240
to: 'BigNumber',
241241
convert: function (x) {
242-
throw new TypeError('Cannot implicitly convert a Fraction to BigNumber or vice versa. ' +
243-
'Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.')
242+
throw new TypeError('无法将分数隐式转换为大数,反之亦然。' +
243+
'使用函数 bignumber(x) 转换为大数或 fraction(x) 转换为分数.')
244244
}
245245
}, {
246246
from: 'Fraction',
@@ -262,9 +262,9 @@ export const createTyped = /* #__PURE__ */ factory('typed', dependencies, functi
262262

263263
const f = new Fraction(x)
264264
if (f.valueOf() !== x) {
265-
throw new TypeError('Cannot implicitly convert a number to a Fraction when there will be a loss of precision ' +
266-
'(value: ' + x + '). ' +
267-
'Use function fraction(x) to convert to Fraction.')
265+
throw new TypeError('当存在精度损失时,无法将一个数字隐式转换为分数' +
266+
'(值: ' + x + '). ' +
267+
'使用函数 fraction(x) 转换为分数.')
268268
}
269269
return f
270270
}
@@ -281,7 +281,7 @@ export const createTyped = /* #__PURE__ */ factory('typed', dependencies, functi
281281
convert: function (x) {
282282
const n = Number(x)
283283
if (isNaN(n)) {
284-
throw new Error('Cannot convert "' + x + '" to a number')
284+
throw new Error('无法将 "' + x + '" 转换为浮点数')
285285
}
286286
return n
287287
}
@@ -296,7 +296,7 @@ export const createTyped = /* #__PURE__ */ factory('typed', dependencies, functi
296296
try {
297297
return new BigNumber(x)
298298
} catch (err) {
299-
throw new Error('Cannot convert "' + x + '" to BigNumber')
299+
throw new Error('无法将 "' + x + '" 转换为大数')
300300
}
301301
}
302302
}, {
@@ -320,7 +320,7 @@ export const createTyped = /* #__PURE__ */ factory('typed', dependencies, functi
320320
try {
321321
return new Fraction(x)
322322
} catch (err) {
323-
throw new Error('Cannot convert "' + x + '" to Fraction')
323+
throw new Error('无法将 "' + x + '" 转换为分数')
324324
}
325325
}
326326
}, {
@@ -334,7 +334,7 @@ export const createTyped = /* #__PURE__ */ factory('typed', dependencies, functi
334334
try {
335335
return new Complex(x)
336336
} catch (err) {
337-
throw new Error('Cannot convert "' + x + '" to Complex')
337+
throw new Error('无法将 "' + x + '" 转换为复数')
338338
}
339339
}
340340
}, {
@@ -405,8 +405,7 @@ export const createTyped = /* #__PURE__ */ factory('typed', dependencies, functi
405405
// check if the function can be unary:
406406
signatures.some(sig => !sig.params.includes(','))) {
407407
const err = new TypeError(
408-
`Function '${name}' doesn't apply to matrices. To call it ` +
409-
`elementwise on a matrix 'M', try 'map(M, ${name})'.`)
408+
`函数 '${name}' 不适用于矩阵。要对矩阵M逐元素调用函数,请使用 'map(M, ${name})'。`)
410409
err.data = usualError.data
411410
throw err
412411
}
@@ -424,8 +423,7 @@ export const createTyped = /* #__PURE__ */ factory('typed', dependencies, functi
424423
// check if the function can be unary:
425424
signatures.some(sig => !sig.params.includes(','))) {
426425
const err = new TypeError(
427-
`Function '${name}' doesn't apply to matrices. To call it ` +
428-
`elementwise on a matrix 'M', try 'map(M, ${name})'.`)
426+
`函数 '${name}' 不适用于矩阵。要对矩阵M逐元素调用函数,请使用 'map(M, ${name})'。`)
429427
err.data = usualError.data
430428
throw err
431429
}
@@ -436,17 +434,17 @@ export const createTyped = /* #__PURE__ */ factory('typed', dependencies, functi
436434
})
437435

438436
function throwNoBignumber (x) {
439-
throw new Error(`Cannot convert value ${x} into a BigNumber: no class 'BigNumber' provided`)
437+
throw new Error(`无法将值 ${x} 转换为大数:未启用大数`)
440438
}
441439

442440
function throwNoComplex (x) {
443-
throw new Error(`Cannot convert value ${x} into a Complex number: no class 'Complex' provided`)
441+
throw new Error(`无法将值 ${x} 转换为复数:未启用复数`)
444442
}
445443

446444
function throwNoMatrix () {
447-
throw new Error('Cannot convert array into a Matrix: no class \'DenseMatrix\' provided')
445+
throw new Error('无法将数组转换为矩阵:未启用矩阵')
448446
}
449447

450448
function throwNoFraction (x) {
451-
throw new Error(`Cannot convert value ${x} into a Fraction, no class 'Fraction' provided.`)
449+
throw new Error(`无法将值 ${x} 转换为分数,未启用分数`)
452450
}

src/error/ArgumentsError.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@
99
*/
1010
export function ArgumentsError (fn, count, min, max) {
1111
if (!(this instanceof ArgumentsError)) {
12-
throw new SyntaxError('Constructor must be called with the new operator')
12+
throw new SyntaxError('构造函数必须使用 new 运算符调用')
1313
}
1414

1515
this.fn = fn
1616
this.count = count
1717
this.min = min
1818
this.max = max
1919

20-
this.message = 'Wrong number of arguments in function ' + fn +
21-
' (' + count + ' provided, ' +
22-
min + ((max !== undefined && max !== null) ? ('-' + max) : '') + ' expected)'
20+
this.message = '函数 ' + fn + ' 参数数量错误 (已提供 ' + count + ' 个参数,需要 ' +
21+
min + ((max !== undefined && max !== null) ? ('-' + max) : '') + ' 个参数)'
2322

2423
this.stack = (new Error()).stack
2524
}

src/error/DimensionError.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
*/
1010
export function DimensionError (actual, expected, relation) {
1111
if (!(this instanceof DimensionError)) {
12-
throw new SyntaxError('Constructor must be called with the new operator')
12+
throw new SyntaxError('构造函数必须使用 new 运算符调用')
1313
}
1414

1515
this.actual = actual
1616
this.expected = expected
1717
this.relation = relation
1818

19-
this.message = 'Dimension mismatch (' +
19+
this.message = '维度不匹配 (' +
2020
(Array.isArray(actual) ? ('[' + actual.join(', ') + ']') : actual) +
2121
' ' + (this.relation || '!=') + ' ' +
2222
(Array.isArray(expected) ? ('[' + expected.join(', ') + ']') : expected) +

src/error/IndexError.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
export function IndexError (index, min, max) {
1212
if (!(this instanceof IndexError)) {
13-
throw new SyntaxError('Constructor must be called with the new operator')
13+
throw new SyntaxError('构造函数必须使用 new 运算符调用')
1414
}
1515

1616
this.index = index
@@ -23,11 +23,11 @@ export function IndexError (index, min, max) {
2323
}
2424

2525
if (this.min !== undefined && this.index < this.min) {
26-
this.message = 'Index out of range (' + this.index + ' < ' + this.min + ')'
26+
this.message = '索引超出范围 (' + this.index + ' < ' + this.min + ')'
2727
} else if (this.max !== undefined && this.index >= this.max) {
28-
this.message = 'Index out of range (' + this.index + ' > ' + (this.max - 1) + ')'
28+
this.message = '索引超出范围 (' + this.index + ' > ' + (this.max - 1) + ')'
2929
} else {
30-
this.message = 'Index out of range (' + this.index + ')'
30+
this.message = '索引超出范围 (' + this.index + ')'
3131
}
3232

3333
this.stack = (new Error()).stack

src/expression/node/AccessorNode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ export const createAccessorNode = /* #__PURE__ */ factory(name, dependencies, ({
5555
constructor (object, index, optionalChaining = false) {
5656
super()
5757
if (!isNode(object)) {
58-
throw new TypeError('Node expected for parameter "object"')
58+
throw new TypeError('参数 "object" 应为节点')
5959
}
6060
if (!isIndexNode(index)) {
61-
throw new TypeError('IndexNode expected for parameter "index"')
61+
throw new TypeError('参数 "index" 应为索引节点')
6262
}
6363

6464
this.object = object

src/expression/node/ArrayNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const createArrayNode = /* #__PURE__ */ factory(name, dependencies, ({ No
2121

2222
// validate input
2323
if (!Array.isArray(this.items) || !this.items.every(isNode)) {
24-
throw new TypeError('Array containing Nodes expected')
24+
throw new TypeError('应为包含节点的数组')
2525
}
2626
}
2727

src/expression/node/AssignmentNode.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ export const createAssignmentNode = /* #__PURE__ */ factory(name, dependencies,
7474

7575
// validate input
7676
if (!isSymbolNode(object) && !isAccessorNode(object)) {
77-
throw new TypeError('SymbolNode or AccessorNode expected as "object"')
77+
throw new TypeError('应为 SymbolNode AccessorNode 作为 "object"')
7878
}
7979
if (isSymbolNode(object) && object.name === 'end') {
80-
throw new Error('Cannot assign to symbol "end"')
80+
throw new Error('无法分配给符号 "end"')
8181
}
8282
if (this.index && !isIndexNode(this.index)) { // index is optional
83-
throw new TypeError('IndexNode expected as "index"')
83+
throw new TypeError('应为索引节点作为 "index"')
8484
}
8585
if (!isNode(this.value)) {
86-
throw new TypeError('Node expected as "value"')
86+
throw new TypeError('应为节点作为 "value"')
8787
}
8888
}
8989

@@ -126,7 +126,7 @@ export const createAssignmentNode = /* #__PURE__ */ factory(name, dependencies,
126126
if (!this.index) {
127127
// apply a variable to the scope, for example `a=2`
128128
if (!isSymbolNode(this.object)) {
129-
throw new TypeError('SymbolNode expected as object')
129+
throw new TypeError('应为 SymbolNode 作为对象')
130130
}
131131

132132
return function evalAssignmentNode (scope, args, context) {

src/expression/node/BlockNode.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ export const createBlockNode = /* #__PURE__ */ factory(name, dependencies, ({ Re
2323
constructor (blocks) {
2424
super()
2525
// validate input, copy blocks
26-
if (!Array.isArray(blocks)) throw new Error('Array expected')
26+
if (!Array.isArray(blocks)) throw new Error('应为数组')
2727
this.blocks = blocks.map(function (block) {
2828
const node = block && block.node
2929
const visible = block &&
3030
block.visible !== undefined
3131
? block.visible
3232
: true
3333

34-
if (!isNode(node)) throw new TypeError('Property "node" must be a Node')
35-
if (typeof visible !== 'boolean') { throw new TypeError('Property "visible" must be a boolean') }
34+
if (!isNode(node)) throw new TypeError('属性 "node" 必须为节点')
35+
if (typeof visible !== 'boolean') { throw new TypeError('属性 "visible" 必须为布尔值') }
3636

3737
return { node, visible }
3838
})

src/expression/node/ConditionalNode.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const createConditionalNode = /* #__PURE__ */ factory(name, dependencies,
3838
return false
3939
}
4040

41-
throw new TypeError('Unsupported type of condition "' + typeOf(condition) + '"')
41+
throw new TypeError('不支持的条件类型 "' + typeOf(condition) + '"')
4242
}
4343

4444
class ConditionalNode extends Node {
@@ -54,9 +54,9 @@ export const createConditionalNode = /* #__PURE__ */ factory(name, dependencies,
5454
*/
5555
constructor (condition, trueExpr, falseExpr) {
5656
super()
57-
if (!isNode(condition)) { throw new TypeError('Parameter condition must be a Node') }
58-
if (!isNode(trueExpr)) { throw new TypeError('Parameter trueExpr must be a Node') }
59-
if (!isNode(falseExpr)) { throw new TypeError('Parameter falseExpr must be a Node') }
57+
if (!isNode(condition)) { throw new TypeError('参数 condition 必须为节点') }
58+
if (!isNode(trueExpr)) { throw new TypeError('参数 trueExpr 必须为节点') }
59+
if (!isNode(falseExpr)) { throw new TypeError('参数 falseExpr 必须为节点') }
6060

6161
this.condition = condition
6262
this.trueExpr = trueExpr

src/expression/node/SymbolNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const createSymbolNode = /* #__PURE__ */ factory(name, dependencies, ({ m
106106
* @param {string} name
107107
*/
108108
static onUndefinedSymbol (name) {
109-
throw new Error('Undefined symbol ' + name)
109+
throw new Error('符号 ' + name + ' 未定义')
110110
}
111111

112112
/**

0 commit comments

Comments
 (0)