webpack-gc-i18n-plugin 1.1.0 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,690 @@
1
- import { OptionInfo } from 'gc-i18n-plugin-core';
2
- export * from 'gc-i18n-plugin-core';
1
+ import { types } from '@babel/core';
2
+ import tunnel from 'tunnel';
3
+ import { AxiosProxyConfig } from 'axios';
4
+ import { Node } from '@babel/types';
3
5
  import webpack from 'webpack';
4
6
 
7
+ interface TranslatorOption {
8
+ /** Translator版本,用于做后续的功能迭代 */
9
+ version?: number;
10
+ /**
11
+ * 实际的请求方法
12
+ * @param text 被翻译的文本
13
+ * @param fromKey 源语言
14
+ * @param toKey 目标语言
15
+ * @param separator 分隔符
16
+ * @returns 翻译后的文本
17
+ */
18
+ fetchMethod: (text: string, fromKey: string, toKey: string, separator: string) => Promise<string>;
19
+ name: string;
20
+ /** 单次最大翻译文本长度 */
21
+ maxChunkSize?: number;
22
+ /** 执行间隔(默认不开启) */
23
+ interval?: number;
24
+ /**
25
+ * 错误处理函数,主要是打印提示
26
+ * @param err 抛出的异常
27
+ * @param defaultErrorHandler 默认的错误处理函数
28
+ * @returns 如果在这里抛出异常会中断翻译
29
+ */
30
+ onError?: (err: unknown, defaultErrorHandler: (error: unknown) => void) => void;
31
+ }
32
+ declare class Translator {
33
+ option: Required<TranslatorOption>;
34
+ constructor(option: TranslatorOption);
35
+ private defaultErrorHandler;
36
+ private getResultOption;
37
+ protected getErrorMessage(error: unknown): string;
38
+ translate(text: string, fromKey: string, toKey: string, separator: string): Promise<string>;
39
+ }
40
+
41
+ interface GoogleTranslatorOption {
42
+ proxyOption?: tunnel.ProxyOptions;
43
+ /** 翻译api执行间隔,默认为1000 */
44
+ interval?: number;
45
+ insertOption?: {
46
+ [key: string]: any;
47
+ };
48
+ }
49
+ /**
50
+ * 谷歌翻译器
51
+ *
52
+ * 基于@vitalets/google-translate-api,需要翻墙,不稳定,但是免费
53
+ *
54
+ * 使用方式:
55
+ * ```ts
56
+ * vitePluginsAutoI18n({
57
+ ...
58
+ translator: translator: new GoogleTranslator({
59
+ proxyOption: {
60
+ // 如果你本地的代理在127.0.0.0:8899
61
+ host: '127.0.0.1',
62
+ port: 8899,
63
+ headers: {
64
+ 'User-Agent': 'Node'
65
+ }
66
+ }
67
+ })
68
+ })
69
+ * ```
70
+ */
71
+ declare class GoogleTranslator extends Translator {
72
+ constructor(option: GoogleTranslatorOption);
73
+ }
74
+
75
+ interface YoudaoTranslatorOption {
76
+ appId: string;
77
+ appKey: string;
78
+ /** 网络代理配置 */
79
+ proxy?: AxiosProxyConfig;
80
+ /** 翻译api执行间隔,默认为1000 */
81
+ interval?: number;
82
+ insertOption?: {
83
+ [key: string]: any;
84
+ };
85
+ }
86
+ /**
87
+ * 有道翻译器
88
+ *
89
+ * api文档:https://ai.youdao.com/DOCSIRMA/html/trans/api/wbfy/index.html
90
+ *
91
+ * 使用方式:
92
+ * ```ts
93
+ * vitePluginsAutoI18n({
94
+ ...
95
+ translator: new YoudaoTranslator({
96
+ appId: '你申请的appId',
97
+ appKey: '你申请的appKey'
98
+ })
99
+ })
100
+ * ```
101
+ */
102
+ declare class YoudaoTranslator extends Translator {
103
+ /** 有道的语言类型映射不标准,需要手动控制 */
104
+ private readonly YOUDAO_TRANSLATE_KEY_CONVERT_MAP;
105
+ private truncate;
106
+ private getTranslateKey;
107
+ constructor(option: YoudaoTranslatorOption);
108
+ }
109
+
110
+ interface BaiduTranslatorOption {
111
+ appId: string;
112
+ appKey: string;
113
+ /** 网络代理配置 */
114
+ proxy?: AxiosProxyConfig;
115
+ /** 翻译api执行间隔,默认为1000 */
116
+ interval?: number;
117
+ insertOption?: {
118
+ [key: string]: any;
119
+ };
120
+ }
121
+ /**
122
+ * 百度翻译器
123
+ *
124
+ * api文档:https://api.fanyi.baidu.com/product/113
125
+ *
126
+ * 使用方式:
127
+ * ```ts
128
+ * vitePluginsAutoI18n({
129
+ ...
130
+ translator: new BaiduTranslator({
131
+ appId: '你申请的appId',
132
+ appKey: '你申请的appKey'
133
+ })
134
+ })
135
+ * ```
136
+ */
137
+ declare class BaiduTranslator extends Translator {
138
+ /** 百度的语言类型映射不标准,需要手动控制 */
139
+ protected readonly BAIDU_TRANSLATE_KEY_CONVERT_MAP: Record<string, string>;
140
+ protected getTranslateKey(key: string): string;
141
+ constructor(option: BaiduTranslatorOption);
142
+ }
143
+
144
+ /**
145
+ * 空翻译器,不翻译文本,用于配合某些特殊的操作
146
+ */
147
+ declare class EmptyTranslator extends Translator {
148
+ constructor(option?: Partial<TranslatorOption>);
149
+ }
150
+ /** @deprecated 别名导出,兼容旧版本 */
151
+ declare const ScanTranslator: typeof EmptyTranslator;
152
+
153
+ declare class CNToTWTranslator extends Translator {
154
+ constructor();
155
+ }
156
+
157
+ interface VolcengineTranslatorOption {
158
+ apiKey: string;
159
+ /** 使用的ai模型,可选值请参阅火山引擎控制台的模型列表,如`doubao-1-5-pro-32k-250115`,并请确保使用前已在控制台开通了对应模型 */
160
+ model: string;
161
+ /** 对本项目的简短描述,在有描述的情况下大模型的翻译结果可能会更加准确 */
162
+ desc?: string;
163
+ /** 网络代理配置 */
164
+ proxy?: AxiosProxyConfig;
165
+ /** 翻译api执行间隔,默认为1000 */
166
+ interval?: number;
167
+ insertOption?: {
168
+ [key: string]: any;
169
+ };
170
+ }
171
+ /**
172
+ * 火山引擎翻译器,内置豆包、deepseek等模型
173
+ *
174
+ * 火山引擎大模型介绍:https://www.volcengine.com/docs/82379/1099455
175
+ *
176
+ * api文档:https://www.volcengine.com/docs/82379/1298454
177
+ *
178
+ * 使用方式:
179
+ * ```ts
180
+ * vitePluginsAutoI18n({
181
+ ...
182
+ translator: new VolcengineTranslator({
183
+ apiKey: '你申请的apiKey',
184
+ model: '你要调用的模型,如:`doubao-1-5-pro-32k-250115`,请确保使用前已在控制台开通了对应模型'
185
+ })
186
+ })
187
+ * ```
188
+ */
189
+ declare class VolcengineTranslator extends Translator {
190
+ constructor(option: VolcengineTranslatorOption);
191
+ }
192
+
193
+ declare enum LanguageEnum {
194
+ }
195
+ declare enum OriginLangKeyEnum {
196
+ ZH = "zh-cn",
197
+ EN = "en",
198
+ JA = "ja",
199
+ KO = "ko",
200
+ RU = "ru"
201
+ }
202
+
203
+ declare enum TranslateApiEnum {
204
+ google = "Google",
205
+ youdao = "Youdao"
206
+ }
207
+
208
+ /**
209
+ * 翻译类型枚举
210
+ */
211
+ declare enum TranslateTypeEnum {
212
+ FULL_AUTO = "full-auto",
213
+ SEMI_AUTO = "semi-auto"
214
+ }
215
+
216
+ declare class Vue2Extends {
217
+ handleInitFile: any;
218
+ handleCodeCall: any;
219
+ handleCodeString: any;
220
+ constructor();
221
+ }
222
+
223
+ type BaseExtendsType = {
224
+ /**
225
+ * 处理入口文件
226
+ * @param source - 源文件内容字符串
227
+ * @returns 包含 source 字段的对象,source 为字符串类型
228
+ */
229
+ handleInitFile: (source: string, path: string) => {
230
+ source: string;
231
+ [key: string]: any;
232
+ };
233
+ /**
234
+ * 处理具体代码,返回函数的babel节点
235
+ * @param option - 选项对象,包含多个参数
236
+ * @param option.option - 选项信息,类型为 OptionInfo
237
+ * @param option.hash - 哈希值
238
+ * @param option.value - 默认传入的值,可能经过了 unicode 转码
239
+ * @param option.uncodeValue - value 转码之后的值
240
+ * @param option.namespace - 命名空间
241
+ * @param initFileResult - 处理入口文件时返回的对象
242
+ */
243
+ handleCodeCall: (option: {
244
+ option: OptionInfo;
245
+ hash: any;
246
+ value: any;
247
+ uncodeValue: any;
248
+ namespace: any;
249
+ }, initFileResult: ReturnType<(source: string, path: string) => {
250
+ source: string;
251
+ [key: string]: any;
252
+ }>) => types.CallExpression;
253
+ /**
254
+ * 处理具体代码,返回字符串的babel节点
255
+ * @param option - 选项对象,包含多个参数
256
+ * @param option.option - 选项信息,类型为 OptionInfo
257
+ * @param option.hash - 哈希值
258
+ * @param option.value - 默认传入的值,可能经过了 unicode 转码
259
+ * @param option.uncodeValue - value 转码之后的值
260
+ * @param option.namespace - 命名空间
261
+ * @param initFileResult - 处理入口文件时返回的对象
262
+ */
263
+ handleCodeString: (option: {
264
+ option: OptionInfo;
265
+ hash: any;
266
+ value: any;
267
+ uncodeValue: any;
268
+ namespace: any;
269
+ }, initFileResult: ReturnType<(source: string, path: string) => {
270
+ source: string;
271
+ [key: string]: any;
272
+ }>) => string;
273
+ };
274
+
275
+ /**
276
+ * 默认插件配置选项
277
+ */
278
+ declare const DEFAULT_OPTION: {
279
+ appCode: string;
280
+ /** 是否启用插件,默认启用 */
281
+ enabled: boolean | (() => boolean);
282
+ /** 翻译调用函数,默认为 $t */
283
+ translateKey: string;
284
+ /** 标记不翻译调用函数列表,避免某些调用被错误翻译 */
285
+ excludedCall: string[];
286
+ /** 标记不用翻译的字符串模式数组,默认是匹配文件扩展名 */
287
+ excludedPattern: RegExp[];
288
+ /** 排查不需要翻译的目录下的文件路径(黑名单), 默认不处理node_modules */
289
+ excludedPath: string[];
290
+ /** 指定需要翻译文件的目录路径正则(白名单) */
291
+ includePath: RegExp[];
292
+ /** 配置文件生成位置,默认为 './lang' */
293
+ globalPath: string;
294
+ /** 打包后生成文件的位置,例如 './dist/assets' */
295
+ distPath: string;
296
+ /** 打包后生成文件的主文件名称,默认是 'index' */
297
+ distKey: string;
298
+ /** 来源语言,默认是中文 */
299
+ originLang: OriginLangKeyEnum | string;
300
+ /** 翻译目标语言列表,默认包含英文 */
301
+ targetLangList: string[];
302
+ /** 语言key,用于请求谷歌api和生成配置文件下对应语言的内容文件 */
303
+ langKey: string[];
304
+ /** 命名空间,防止全局命名冲突 */
305
+ namespace: string;
306
+ /** 单位代码 */
307
+ orgCode: string;
308
+ /** 是否启用源码的值作为key */
309
+ useValueAsKey: boolean;
310
+ /** 是否在构建结束之后将最新的翻译重新打包到主包中,默认不打包 */
311
+ buildToDist: boolean;
312
+ /** 是否启用上传翻译文件到服务器,默认开启 */
313
+ uploadEnabled: boolean;
314
+ /** 翻译器,决定自动翻译使用的api与调用方式,默认使用 Google 翻译器并使用7890(clash)端口代理 */
315
+ translator: Translator;
316
+ /** 翻译器配置选项,优先级低于translator */
317
+ translatorOption: TranslatorOption | undefined;
318
+ /**
319
+ * 翻译类型,支持全自动和半自动两种模式
320
+ * 全自动:所有翻译任务自动完成
321
+ * 半自动:需要人工标识,类似于 $t('key') 的方式
322
+ * 默认值为全自动
323
+ */
324
+ translateType: TranslateTypeEnum | string;
325
+ /**
326
+ * 是否重写配置文件,默认为true
327
+ */
328
+ rewriteConfig: boolean;
329
+ /**
330
+ * 通用翻译key,默认使用namespace,如果commonTranslateKey不为空,则使用commonTranslateKey
331
+ */
332
+ commonTranslateKey: string;
333
+ /**
334
+ * 实验性属性,表示是否进行深层扫描字符串,默认为 false
335
+ * 当设置为 true 时,会对代码中的字符串进行更深入的扫描
336
+ */
337
+ deepScan: boolean;
338
+ /**
339
+ * 自定义文件拓展名数组
340
+ */
341
+ insertFileExtensions: string[];
342
+ /**
343
+ * 自定义拓展类,插件默认翻译函数挂载在window上,如果希望自定义翻译函数挂载在其他对象上,可以使用该属性
344
+ * 注意:该属性需要继承BaseExtends类,并且需要实现handleInitFile和handleCodeCall和handleCodeString方法
345
+ */
346
+ translateExtends: BaseExtendsType | null;
347
+ isClear: boolean;
348
+ /**
349
+ * 是否保留空格
350
+ */
351
+ isClearSpace: boolean;
352
+ };
353
+ /**
354
+ * 类型定义:插件配置选项类型
355
+ */
356
+ type OptionType = typeof DEFAULT_OPTION;
357
+ /**
358
+ * 全局插件配置实例,复制自默认配置
359
+ */
360
+ declare let option: OptionType;
361
+ /**
362
+ * 类型定义:用户传入的配置选项
363
+ */
364
+ interface OptionInfo extends Partial<OptionType> {
365
+ }
366
+ /**
367
+ * 初始化插件配置选项
368
+ * @param optionInfo 用户提供的配置选项
369
+ */
370
+ declare function initOption(optionInfo: OptionInfo): {
371
+ appCode: string;
372
+ /** 是否启用插件,默认启用 */
373
+ enabled: boolean | (() => boolean);
374
+ /** 翻译调用函数,默认为 $t */
375
+ translateKey: string;
376
+ /** 标记不翻译调用函数列表,避免某些调用被错误翻译 */
377
+ excludedCall: string[];
378
+ /** 标记不用翻译的字符串模式数组,默认是匹配文件扩展名 */
379
+ excludedPattern: RegExp[];
380
+ /** 排查不需要翻译的目录下的文件路径(黑名单), 默认不处理node_modules */
381
+ excludedPath: string[];
382
+ /** 指定需要翻译文件的目录路径正则(白名单) */
383
+ includePath: RegExp[];
384
+ /** 配置文件生成位置,默认为 './lang' */
385
+ globalPath: string;
386
+ /** 打包后生成文件的位置,例如 './dist/assets' */
387
+ distPath: string;
388
+ /** 打包后生成文件的主文件名称,默认是 'index' */
389
+ distKey: string;
390
+ /** 来源语言,默认是中文 */
391
+ originLang: OriginLangKeyEnum | string;
392
+ /** 翻译目标语言列表,默认包含英文 */
393
+ targetLangList: string[];
394
+ /** 语言key,用于请求谷歌api和生成配置文件下对应语言的内容文件 */
395
+ langKey: string[];
396
+ /** 命名空间,防止全局命名冲突 */
397
+ namespace: string;
398
+ /** 单位代码 */
399
+ orgCode: string;
400
+ /** 是否启用源码的值作为key */
401
+ useValueAsKey: boolean;
402
+ /** 是否在构建结束之后将最新的翻译重新打包到主包中,默认不打包 */
403
+ buildToDist: boolean;
404
+ /** 是否启用上传翻译文件到服务器,默认开启 */
405
+ uploadEnabled: boolean;
406
+ /** 翻译器,决定自动翻译使用的api与调用方式,默认使用 Google 翻译器并使用7890(clash)端口代理 */
407
+ translator: Translator;
408
+ /** 翻译器配置选项,优先级低于translator */
409
+ translatorOption: TranslatorOption | undefined;
410
+ /**
411
+ * 翻译类型,支持全自动和半自动两种模式
412
+ * 全自动:所有翻译任务自动完成
413
+ * 半自动:需要人工标识,类似于 $t('key') 的方式
414
+ * 默认值为全自动
415
+ */
416
+ translateType: TranslateTypeEnum | string;
417
+ /**
418
+ * 是否重写配置文件,默认为true
419
+ */
420
+ rewriteConfig: boolean;
421
+ /**
422
+ * 通用翻译key,默认使用namespace,如果commonTranslateKey不为空,则使用commonTranslateKey
423
+ */
424
+ commonTranslateKey: string;
425
+ /**
426
+ * 实验性属性,表示是否进行深层扫描字符串,默认为 false
427
+ * 当设置为 true 时,会对代码中的字符串进行更深入的扫描
428
+ */
429
+ deepScan: boolean;
430
+ /**
431
+ * 自定义文件拓展名数组
432
+ */
433
+ insertFileExtensions: string[];
434
+ /**
435
+ * 自定义拓展类,插件默认翻译函数挂载在window上,如果希望自定义翻译函数挂载在其他对象上,可以使用该属性
436
+ * 注意:该属性需要继承BaseExtends类,并且需要实现handleInitFile和handleCodeCall和handleCodeString方法
437
+ */
438
+ translateExtends: BaseExtendsType | null;
439
+ isClear: boolean;
440
+ /**
441
+ * 是否保留空格
442
+ */
443
+ isClearSpace: boolean;
444
+ };
445
+ /**
446
+ * 校验插件配置选项是否完整有效
447
+ * @returns {boolean} 校验结果,完整返回 true,否则返回 false
448
+ */
449
+ declare function checkOption(): boolean;
450
+
451
+ declare function getOriginRegex(): RegExp;
452
+ /**
453
+ * @description: 是否包含来源语言字符
454
+ * @param {string} code
455
+ * @return {*}
456
+ */
457
+ declare function hasOriginSymbols(code: string): boolean;
458
+ /**
459
+ * @description: 过滤注释
460
+ * @param {string} code
461
+ * @return {*}
462
+ */
463
+ declare const removeComments: (code: string) => string;
464
+ /**
465
+ * @description: 用于判断提供的值是否符合正则表达式数组中的任一规则,符合则跳过
466
+ * @param {*} value
467
+ * @param {*} regexArray
468
+ * @return {*}
469
+ */
470
+ declare function checkAgainstRegexArray(value: string, regexArray: string[] | RegExp[]): boolean;
471
+ /**
472
+ * @description: 用于解析抽象语法树中的调用表达式,并提取出调用的名称,如a.b.c() 取 c。
473
+ * @param {any} node
474
+ * @return {*}
475
+ */
476
+ declare function extractFunctionName(node: Node): string;
477
+ /**
478
+ * @description: 提取文件的中文部分
479
+ * @param {string} fileContent
480
+ * @return {*}
481
+ */
482
+ declare const extractCnStrings: (fileContent: string) => string[];
483
+ /**
484
+ * @description: 提取文件指定部分内容
485
+ * @param {string} fileContent
486
+ * @param {any} regex
487
+ * @return {*}
488
+ */
489
+ declare function extractStrings(fileContent: string, regex: any): string[];
490
+ /**
491
+ * @description: 生成i8n翻译函数
492
+ * @param {string} value
493
+ * @param {boolean} isExpression
494
+ * @param {string} key
495
+ * @return {*}
496
+ */
497
+ declare function createI18nTranslator(createOption: {
498
+ value: string;
499
+ isExpression?: boolean;
500
+ key?: string;
501
+ insertOption?: any;
502
+ }): any;
503
+ declare function normalizeTranslateValue(value: string): {
504
+ trimmedValue: string;
505
+ valStr: string;
506
+ };
507
+ /**
508
+ * @description: 生成唯一id
509
+ * @param {string} key
510
+ * @return {*}
511
+ */
512
+ declare function generateId(key: string): string;
513
+ /**
514
+ * @description: unicode转普通字符串
515
+ * @param {string} str
516
+ * @return {*}
517
+ */
518
+ declare const unicodeToString: (str: string) => string;
519
+ /**
520
+ * @description: 有道翻译 标识截取
521
+ * @param {string} q
522
+ * @return {*}
523
+ */
524
+ declare function truncate(q: string): string;
525
+ declare function cloneDeep<T>(value: T, cache?: WeakMap<object, any>): T;
526
+
527
+ declare const base_checkAgainstRegexArray: typeof checkAgainstRegexArray;
528
+ declare const base_cloneDeep: typeof cloneDeep;
529
+ declare const base_createI18nTranslator: typeof createI18nTranslator;
530
+ declare const base_extractCnStrings: typeof extractCnStrings;
531
+ declare const base_extractFunctionName: typeof extractFunctionName;
532
+ declare const base_extractStrings: typeof extractStrings;
533
+ declare const base_generateId: typeof generateId;
534
+ declare const base_getOriginRegex: typeof getOriginRegex;
535
+ declare const base_hasOriginSymbols: typeof hasOriginSymbols;
536
+ declare const base_normalizeTranslateValue: typeof normalizeTranslateValue;
537
+ declare const base_removeComments: typeof removeComments;
538
+ declare const base_truncate: typeof truncate;
539
+ declare const base_unicodeToString: typeof unicodeToString;
540
+ declare namespace base {
541
+ export { base_checkAgainstRegexArray as checkAgainstRegexArray, base_cloneDeep as cloneDeep, base_createI18nTranslator as createI18nTranslator, base_extractCnStrings as extractCnStrings, base_extractFunctionName as extractFunctionName, base_extractStrings as extractStrings, base_generateId as generateId, base_getOriginRegex as getOriginRegex, base_hasOriginSymbols as hasOriginSymbols, base_normalizeTranslateValue as normalizeTranslateValue, base_removeComments as removeComments, base_truncate as truncate, base_unicodeToString as unicodeToString };
542
+ }
543
+
544
+ /**
545
+ * @description: 新建国际化配置文件夹
546
+ * @return {*}
547
+ */
548
+ declare function initLangFile(): void;
549
+ /**
550
+ * @description: 初始化翻译基础函数文件
551
+ * @returns {void}
552
+ */
553
+ declare function initTranslateBasicFnFile(): Promise<void>;
554
+ /**
555
+ * @description: 生成国际化JSON文件
556
+ * @return {*}
557
+ */
558
+ declare function initLangTranslateJSONFile(): void;
559
+ /**
560
+ * @description: 读取国际化JSON文件
561
+ * @return {*}
562
+ */
563
+ declare function getLangTranslateJSONFile(): string;
564
+ /**
565
+ * @description: 基于langKey获取JSON配置文件中对应语言对象
566
+ * @param {string} key
567
+ * @return {*}
568
+ */
569
+ declare function getLangObjByJSONFileWithLangKey(key: string, insertJSONObj?: object | undefined): Record<string, any>;
570
+ /**
571
+ * @description: 设置国际化JSON文件
572
+ * @return {*}
573
+ */
574
+ declare function setLangTranslateJSONFile(obj: object): void;
575
+ /**
576
+ * @description: 构建时把lang配置文件设置到打包后到主文件中
577
+ * @return {*}
578
+ */
579
+ declare function uploadFile(): void;
580
+
581
+ declare const file_getLangObjByJSONFileWithLangKey: typeof getLangObjByJSONFileWithLangKey;
582
+ declare const file_getLangTranslateJSONFile: typeof getLangTranslateJSONFile;
583
+ declare const file_initLangFile: typeof initLangFile;
584
+ declare const file_initLangTranslateJSONFile: typeof initLangTranslateJSONFile;
585
+ declare const file_initTranslateBasicFnFile: typeof initTranslateBasicFnFile;
586
+ declare const file_setLangTranslateJSONFile: typeof setLangTranslateJSONFile;
587
+ declare const file_uploadFile: typeof uploadFile;
588
+ declare namespace file {
589
+ export { file_getLangObjByJSONFileWithLangKey as getLangObjByJSONFileWithLangKey, file_getLangTranslateJSONFile as getLangTranslateJSONFile, file_initLangFile as initLangFile, file_initLangTranslateJSONFile as initLangTranslateJSONFile, file_initTranslateBasicFnFile as initTranslateBasicFnFile, file_setLangTranslateJSONFile as setLangTranslateJSONFile, file_uploadFile as uploadFile };
590
+ }
591
+
592
+ declare const SEPARATOR = "\n\u2507\u2507\u2507\n";
593
+ declare const SPLIT_SEPARATOR_REGEX: RegExp;
594
+ type langObj = {
595
+ [key: string]: string;
596
+ };
597
+ declare let langObj: langObj;
598
+ /**
599
+ * @description: 设置翻译对象属性
600
+ * @param {string} key
601
+ * @param {string} value
602
+ * @return {*}
603
+ */
604
+ declare function setLangObj(key: string, value: string): void;
605
+ /**
606
+ * @description: 读取翻译对象
607
+ * @return {*}
608
+ */
609
+ declare function getLangObj(): langObj;
610
+ /**
611
+ * @description: 初始化翻译对象
612
+ * @param {langObj} obj
613
+ * @return {*}
614
+ */
615
+ declare function initLangObj(obj: langObj): void;
616
+ /**
617
+ * 自动生成多语言配置文件的核心方法
618
+ *
619
+ * 主要流程:
620
+ * 1. 加载现有翻译文件
621
+ * 2. 对比找出新增需要翻译的内容
622
+ * 3. 分块并行翻译所有目标语言
623
+ * 4. 合并翻译结果并生成最终配置文件
624
+ *
625
+ * 异常处理:
626
+ * - 翻译结果不完整时中断流程
627
+ * - 文件读写失败时明确报错
628
+ */
629
+ declare function autoTranslate(): Promise<void>;
630
+ /**
631
+ * @description: 新增语言类型配置补全
632
+ * @param {any} obj
633
+ * @return {*}
634
+ */
635
+ declare function languageConfigCompletion(obj: any): void;
636
+ /**
637
+ * @description: 补全新增语言翻译写入函数
638
+ * @param langObj
639
+ * @param curLangObj
640
+ * @param translateKey
641
+ * @return
642
+ */
643
+ declare function completionTranslateAndWriteConfigFile(langObj: Record<string, string>, curLangObj: Record<string, string>, translateKey: string): Promise<void>;
644
+ /**
645
+ * @description: 清理多余的翻译配置JSON文件
646
+ * @return {void} 无返回值
647
+ */
648
+ declare function cleanupUnusedTranslations(): void;
649
+
650
+ declare const translate_SEPARATOR: typeof SEPARATOR;
651
+ declare const translate_SPLIT_SEPARATOR_REGEX: typeof SPLIT_SEPARATOR_REGEX;
652
+ declare const translate_autoTranslate: typeof autoTranslate;
653
+ declare const translate_cleanupUnusedTranslations: typeof cleanupUnusedTranslations;
654
+ declare const translate_completionTranslateAndWriteConfigFile: typeof completionTranslateAndWriteConfigFile;
655
+ declare const translate_getLangObj: typeof getLangObj;
656
+ declare const translate_initLangObj: typeof initLangObj;
657
+ declare const translate_langObj: typeof langObj;
658
+ declare const translate_languageConfigCompletion: typeof languageConfigCompletion;
659
+ declare const translate_setLangObj: typeof setLangObj;
660
+ declare namespace translate {
661
+ export { translate_SEPARATOR as SEPARATOR, translate_SPLIT_SEPARATOR_REGEX as SPLIT_SEPARATOR_REGEX, translate_autoTranslate as autoTranslate, translate_cleanupUnusedTranslations as cleanupUnusedTranslations, translate_completionTranslateAndWriteConfigFile as completionTranslateAndWriteConfigFile, translate_getLangObj as getLangObj, translate_initLangObj as initLangObj, translate_langObj as langObj, translate_languageConfigCompletion as languageConfigCompletion, translate_setLangObj as setLangObj };
662
+ }
663
+
664
+ declare function upload(json: object): Promise<void>;
665
+
666
+ declare const upload$1_upload: typeof upload;
667
+ declare namespace upload$1 {
668
+ export { upload$1_upload as upload };
669
+ }
670
+
671
+ declare class FunctionFactoryOption {
672
+ static originLang: string;
673
+ }
674
+
675
+ declare function export_default(insertOption?: any): () => {
676
+ visitor: {
677
+ StringLiteral: (path: any) => void;
678
+ JSXText: (path: any) => void;
679
+ TemplateLiteral: (path: any) => void;
680
+ CallExpression: (path: any) => void;
681
+ };
682
+ };
683
+
684
+ declare namespace index {
685
+ export { export_default as default };
686
+ }
687
+
5
688
  /**
6
689
  * Webpack 插件实现,用于自动化处理国际化翻译功能
7
690
  */
@@ -18,4 +701,4 @@ declare class webpackPluginsAutoI18n {
18
701
  apply(compiler: webpack.Compiler): void;
19
702
  }
20
703
 
21
- export { webpackPluginsAutoI18n as default };
704
+ export { BaiduTranslator, type BaiduTranslatorOption, type BaseExtendsType, CNToTWTranslator, EmptyTranslator, FunctionFactoryOption, GoogleTranslator, type GoogleTranslatorOption, LanguageEnum, type OptionInfo, OriginLangKeyEnum, ScanTranslator, TranslateApiEnum, TranslateTypeEnum, Translator, type TranslatorOption, VolcengineTranslator, type VolcengineTranslatorOption, Vue2Extends, YoudaoTranslator, type YoudaoTranslatorOption, base as baseUtils, checkOption, webpackPluginsAutoI18n as default, file as fileUtils, index as filter, initOption, option, translate as translateUtils, upload$1 as uploadUtils };