chore: replace all cn comments of fe to en version by volc api (#320)

This commit is contained in:
tecvan
2025-07-31 10:32:15 +08:00
committed by GitHub
parent 716ec0cba8
commit 71f6245a01
2960 changed files with 15545 additions and 15545 deletions

View File

@@ -139,14 +139,14 @@ export class AdapterPlugin implements IPlugin {
getAnnotation(f.annotations, 'api.converter') === 'atoi_comp_empty'
) {
if (isInt(f.fieldType)) {
// 类型转换为 string
// Type conversion to string
f.fieldType.type = SyntaxType.StringKeyword;
}
}
// api.converter int 以及 map 类型生效
// Api.converter works for int and map types
if (getAnnotation(f.annotations, 'api.converter') === 'itoa') {
if (isInt(f.fieldType)) {
// 类型转换为 string
// Type conversion to string
f.fieldType.type = SyntaxType.StringKeyword;
}
if (isMapType(f.fieldType)) {
@@ -156,7 +156,7 @@ export class AdapterPlugin implements IPlugin {
}
}
}
// item_converter list 类型生效
// item_converter for list types
if (
['atoi_comp_empty', 'itoa'].includes(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -168,24 +168,24 @@ export class AdapterPlugin implements IPlugin {
}
}
// 收集 decode encode 注解处理
// Collection decoding encoding annotation processing
if (getTypeFromDynamicJsonAnnotation(f.annotations)) {
decodeEncodeFields.push(f.name.value);
}
// api.json 注解处理
// api.json annotation processing
const jsonAnnotation = getAnnotation(f.annotations, 'api.json');
if (jsonAnnotation) {
f.extensionConfig = f.extensionConfig || {};
f.extensionConfig.key = jsonAnnotation;
}
// api.json_string 注解处理
// API. json_string annotation handling
const jsonStrAnnotation = getAnnotation(
f.annotations,
'api.json_string',
);
if (jsonStrAnnotation) {
if (isInt(f.fieldType)) {
// 类型转换为 string
// Type conversion to string
f.fieldType.type = SyntaxType.StringKeyword;
f.extensionConfig = f.extensionConfig || {};
f.extensionConfig.key = jsonStrAnnotation;

View File

@@ -403,7 +403,7 @@ export class ClientPlugin implements IPlugin {
});
const enumAst = t.tsEnumDeclaration(t.identifier(name.value), enumArr);
// 从后向前删除枚举项,避免索引变化影响
// Delete enumeration items from back to front to avoid the impact of index changes
enumItemIndexArray
.sort((a, b) => b - a)
.forEach(index => {

View File

@@ -21,7 +21,7 @@ import { type Contexts, HOOK } from '../context';
const MAGIC_COMMENT_KEY = '\n*@magic-comment';
// 忽略 struct 中的字段
// Ignore fields in struct
export class CommentFormatPlugin {
apply(p: Program<Contexts>) {
p.register(after('PARSE_ENTRY'), ctx => {

View File

@@ -26,7 +26,7 @@ interface IPops {
filter: Filter;
}
// 忽略 struct 中的字段
// Ignore fields in struct
export class IgnoreStructFiledPlugin {
private filter: Filter;
constructor({ filter }: IPops) {

View File

@@ -56,7 +56,7 @@ export class MetaPlugin implements IPlugin {
ctx => {
const node = ctx.node as ServiceDefinition;
node.functions.forEach(fun => {
// 过滤非泛化接口
// Filtering non-generalized interfaces
if (!fun.extensionConfig?.method) {
return;
}
@@ -103,7 +103,7 @@ export class MetaPlugin implements IPlugin {
schemaRoot: getSchemaRootByPath(ast.idlPath, this.options.idlRoot),
service,
} as IMeta;
// 不是 json 时,需要加上 serializer 标识
// When not json, you need to add the serializer flag.
if (extensionConfig?.serializer && extensionConfig?.serializer !== 'json') {
res.serializer = extensionConfig?.serializer;
}
@@ -117,7 +117,7 @@ export class MetaPlugin implements IPlugin {
if (isStructDefinition(statement)) {
const wholeBody = statement.fields.find(isFullBody);
if (wholeBody) {
// 处理 api.body="." 以及 api.full_body=''
// Handle api.body = "." and api.full_body = "
return `${id.value}['${getFieldsAlias(wholeBody)}']`;
} else {
return id.value;
@@ -184,7 +184,7 @@ export class MetaPlugin implements IPlugin {
}
});
}
// 如果没有指定根据method默认指定为query 或者 body
// If not specified, it is specified as query or body by default according to method.
if (!specificPositionFiled.has(alias)) {
const filedMapping = mapping[defaultPosition];
mapping[defaultPosition] = filedMapping

View File

@@ -110,7 +110,7 @@ export class MockTransformerPlugin implements IPlugin {
nextOrder[name] = index;
}
});
// 按照 mock 文件中的顺序优先排序
// Prioritize in order in the mock file
const getOrder = (name: string) =>
typeof mockVarOrder[name] !== 'undefined'
? mockVarOrder[name]
@@ -210,7 +210,7 @@ export class MockTransformerPlugin implements IPlugin {
if (isStructDefinition(statement)) {
const wholeBody = statement.fields.find(isFullBody);
if (wholeBody) {
// 处理 api.body="."
// Processing api.body = "."
const { annotations } = wholeBody;
if (hasDynamicJsonAnnotation(annotations)) {
return '{}';
@@ -273,7 +273,7 @@ export class MockTransformerPlugin implements IPlugin {
if (!fieldNames.has(fieldName)) {
return;
}
// 没有的,需要重新生成
// No, it needs to be regenerated.
newPros.push(
t.objectProperty(
fieldName.includes('-')
@@ -351,11 +351,11 @@ export class MockTransformerPlugin implements IPlugin {
const { valueType } = fieldType;
output = t.arrayExpression([this.processValue(valueType)]);
} else if (isSetType(fieldType)) {
// set 处理成array校验
// Set to array validation
const { valueType } = fieldType;
output = t.arrayExpression([this.processValue(valueType)]);
} else if (isIdentifier(fieldType)) {
// 引用类型
// reference type
const { refName, namespace } = parseIdFiledType(fieldType);
if (!namespace) {
output = t.callExpression(t.identifier(refName), []);
@@ -375,7 +375,7 @@ export class MockTransformerPlugin implements IPlugin {
throw new Error(`can not process fieldType : ${fieldType.type}`);
}
private processConst(constVal: ConstValue) {
// 暂时统一处理成0
// Temporarily unified processing to 0
if (isStringLiteral(constVal)) {
return t.stringLiteral(constVal.value);
}
@@ -410,11 +410,11 @@ export class MockTransformerPlugin implements IPlugin {
const comment = { type: 'CommentLine', value: commentValues } as any;
const target = this.findTarget(name.value, ctx);
if (target) {
// 需要更新注释
// Comments need to be updated
// target.trailingComments = [comment];
return;
}
// 枚举类型统一处理成常量
// Enumeration types are uniformly processed into constants
const builder = template(`var ${name.value}= () => %%value%% `);
const node = builder({
value: t.numericLiteral(values[0] || 0),
@@ -437,7 +437,7 @@ export class MockTransformerPlugin implements IPlugin {
// const variableDeclaration = t.addComment(
// ,
// 'leading',
// '暂时对const默认处理为0如有需要请自行重新赋值'
// 'Temporarily, the default processing for const is 0, please reassign it yourself if necessary '
// );
return node;
}

View File

@@ -29,7 +29,7 @@ import { type Options } from '../types';
import { type Contexts, HOOK } from '../context';
/**
* 提供统一 api 入口
* Provide unified API entry
*/
export class PkgEntryPlugin implements IPlugin {
private options: Options;
@@ -52,7 +52,7 @@ export class PkgEntryPlugin implements IPlugin {
);
this.funcs.set(
relativePath,
// 只支持单 service
// Only single service supported
meta[0].service,
);
return ctx;

View File

@@ -223,7 +223,7 @@ export class SchemaPlugin implements IPlugin {
};
return schema;
} else if (isSetType(fieldType)) {
// set 处理成array校验
// Set to array validation
const { valueType } = fieldType;
const schema: ListType = {
type: 'array',
@@ -231,7 +231,7 @@ export class SchemaPlugin implements IPlugin {
};
return schema;
} else if (isIdentifier(fieldType)) {
// 引用类型
// reference type
const { refName, namespace } = parseIdFiledType(fieldType);
if (!namespace) {
const schema: RefType = { $ref: `#/definitions/${refName}` };
@@ -249,7 +249,7 @@ export class SchemaPlugin implements IPlugin {
throw new Error(`can not process fieldType : ${fieldType.type}`);
}
private processConst(constVal: ConstValue) {
// 暂时统一处理成0
// Temporarily unified processing to 0
const schema = {} as ConstType;
if (isStringLiteral(constVal)) {
schema.const = constVal.value;