i18n-easy 1.0.0
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/README.md +527 -0
- package/esm/assets/const.js +7 -0
- package/esm/ast_transformer.d.ts +19 -0
- package/esm/ast_transformer.js +54 -0
- package/esm/eslint/react/i18n_easy_plugin.d.ts +3 -0
- package/esm/eslint/react/i18n_easy_plugin.js +111 -0
- package/esm/eslint/react/i18n_utils.d.ts +61 -0
- package/esm/eslint/react/i18n_utils.js +115 -0
- package/esm/eslint/react/report_and_fix.d.ts +67 -0
- package/esm/eslint/react/report_and_fix.js +118 -0
- package/esm/eslint/vue/i18n_easy_plugin.d.ts +5 -0
- package/esm/eslint/vue/i18n_easy_plugin.js +141 -0
- package/esm/eslint/vue/i18n_utils.d.ts +65 -0
- package/esm/eslint/vue/i18n_utils.js +133 -0
- package/esm/eslint/vue/report_and_fix.d.ts +8 -0
- package/esm/eslint/vue/report_and_fix.js +169 -0
- package/esm/file_processor_utils.d.ts +14 -0
- package/esm/file_processor_utils.js +68 -0
- package/esm/i18n_easy.d.ts +77 -0
- package/esm/i18n_easy.js +171 -0
- package/esm/index.d.ts +4 -0
- package/esm/index.js +9 -0
- package/esm/key_map.d.ts +14 -0
- package/esm/key_map.js +51 -0
- package/esm/patch.d.ts +5 -0
- package/esm/progressBus.d.ts +7 -0
- package/esm/progressBus.js +25 -0
- package/esm/translate.d.ts +34 -0
- package/esm/translate.js +107 -0
- package/esm/type.d.ts +94 -0
- package/esm/type.js +0 -0
- package/esm/utils.d.ts +54 -0
- package/esm/utils.js +102 -0
- package/lib/assets/const.js +32 -0
- package/lib/ast_transformer.js +88 -0
- package/lib/cli.d.ts +2 -0
- package/lib/cli.js +5 -0
- package/lib/eslint/react/i18n_easy_plugin.js +131 -0
- package/lib/eslint/react/i18n_utils.js +145 -0
- package/lib/eslint/react/report_and_fix.js +156 -0
- package/lib/eslint/vue/i18n_easy_plugin.js +161 -0
- package/lib/eslint/vue/i18n_utils.js +164 -0
- package/lib/eslint/vue/report_and_fix.js +203 -0
- package/lib/file_processor_utils.js +109 -0
- package/lib/i18n_easy.js +205 -0
- package/lib/index.js +35 -0
- package/lib/key_map.js +71 -0
- package/lib/package.json +3 -0
- package/lib/patch.d.ts +5 -0
- package/lib/progressBus.js +50 -0
- package/lib/translate.js +127 -0
- package/lib/type.js +17 -0
- package/lib/utils.js +142 -0
- package/package.json +68 -0
- package/types/assets/const.d.ts +2 -0
- package/types/ast_transformer.d.ts +19 -0
- package/types/eslint/react/i18n_easy_plugin.d.ts +3 -0
- package/types/eslint/react/i18n_utils.d.ts +61 -0
- package/types/eslint/react/report_and_fix.d.ts +67 -0
- package/types/eslint/vue/i18n_easy_plugin.d.ts +5 -0
- package/types/eslint/vue/i18n_utils.d.ts +65 -0
- package/types/eslint/vue/report_and_fix.d.ts +8 -0
- package/types/file_processor_utils.d.ts +14 -0
- package/types/i18n_easy.d.ts +77 -0
- package/types/index.d.ts +4 -0
- package/types/key_map.d.ts +14 -0
- package/types/progressBus.d.ts +6 -0
- package/types/translate.d.ts +34 -0
- package/types/type.d.ts +94 -0
- package/types/utils.d.ts +54 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ESLint } from 'eslint';
|
|
2
|
+
import { BaseCodeType, TextNode } from '../../type.js';
|
|
3
|
+
export type CollectNodes = (textNode: TextNode, codeType: Extract<BaseCodeType, 'js' | 'jsx' | 'script' | 'template'>) => void;
|
|
4
|
+
declare const VuePlugin: ESLint.Plugin;
|
|
5
|
+
export default VuePlugin;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import type { AST } from 'vue-eslint-parser';
|
|
3
|
+
import * as ESTree from 'estree';
|
|
4
|
+
import { TextNode, SetUpNode, CodeType } from '../../type.js';
|
|
5
|
+
/**
|
|
6
|
+
* @description 创建i18n-ignore注释检查器
|
|
7
|
+
* @param context - ESLint规则上下文
|
|
8
|
+
* @param templateBody - Vue模板体节点
|
|
9
|
+
* @returns 检查节点是否被忽略的函数
|
|
10
|
+
*/
|
|
11
|
+
export declare function createI18nIgnoreChecker(context: Rule.RuleContext, templateBody: AST.VElement & AST.HasConcreteInfo): (node: any) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* @description 判断能否注入
|
|
14
|
+
* @param context - ESLint规则上下文
|
|
15
|
+
* @param node - Program节点、FunctionExpression节点、ArrowFunctionExpression节点
|
|
16
|
+
* @param codeType - 代码类型
|
|
17
|
+
* @returns 是否能注入
|
|
18
|
+
*/
|
|
19
|
+
export declare function callNameNotExist(context: Rule.RuleContext, node: SetUpNode, codeType: Exclude<CodeType, 'template'>): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 1、不存在节点返回null
|
|
22
|
+
* 2、存在import节点,返回最后一个import节点
|
|
23
|
+
* 3、不存在import节点,返回第一个非import节点
|
|
24
|
+
* @description 获取最后一个 import 或第一个非 import 节点
|
|
25
|
+
* @param context - ESLint规则上下文
|
|
26
|
+
* @returns 最后一个 import 节点或第一个非 import 节点或 null
|
|
27
|
+
*/
|
|
28
|
+
export declare function getLastImportOrFirstNotImportNode(context: Rule.RuleContext): {
|
|
29
|
+
node: ESTree.Node;
|
|
30
|
+
type: string;
|
|
31
|
+
} | null;
|
|
32
|
+
/**
|
|
33
|
+
* @description 获取hooks注入节点
|
|
34
|
+
* @param context - ESLint规则上下文
|
|
35
|
+
* @param node - BlockStatement节点或Program节点
|
|
36
|
+
* @returns 注入节点或null
|
|
37
|
+
*/
|
|
38
|
+
export declare function getInjectNode(context: Rule.RuleContext, node: ESTree.BlockStatement | ESTree.Program): ESTree.Comment | ESTree.ModuleDeclaration | ESTree.Statement;
|
|
39
|
+
/**
|
|
40
|
+
* 判断能否收集操作节点
|
|
41
|
+
* 排除:
|
|
42
|
+
* 1、使用@i18n-ignore注释的节点
|
|
43
|
+
* 2、未使用中文的节点
|
|
44
|
+
* @description 判断能否收集操作节点
|
|
45
|
+
* @param node - TextNode节点
|
|
46
|
+
* @param isIgnored - 判断节点是否被忽略的函数
|
|
47
|
+
* @returns 是否能收集操作节点
|
|
48
|
+
*/
|
|
49
|
+
export declare function canCollectOperateNodes(node: TextNode, isIgnored: (n: TextNode) => boolean): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* @description 获取节点前的空格
|
|
52
|
+
* @param context - ESLint规则上下文
|
|
53
|
+
* @param node - 节点
|
|
54
|
+
* @returns 节点前的空格
|
|
55
|
+
*/
|
|
56
|
+
export declare function getLeadingSpaces(context: Rule.RuleContext, node: ESTree.Node | ESTree.Comment): string;
|
|
57
|
+
/**
|
|
58
|
+
* @description 获取国际化调用方法
|
|
59
|
+
* @param callMethodName - 国际化调用方法
|
|
60
|
+
* @param key - 国际化键值
|
|
61
|
+
* @param value - 国际化参数
|
|
62
|
+
* @returns 国际化调用方法
|
|
63
|
+
*/
|
|
64
|
+
export declare function getI18nCallMethod(callMethodName: string, key: string, value?: string): string;
|
|
65
|
+
export declare function isScriptSetup(context: Rule.RuleContext): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { CollectListType } from '../../type.js';
|
|
3
|
+
/**
|
|
4
|
+
* @description 批量执行修复函数 根据收集到节点生成修复函数并执行
|
|
5
|
+
* @param context - 规则上下文
|
|
6
|
+
* @param state - 收集到的节点信息
|
|
7
|
+
*/
|
|
8
|
+
export declare function batchFixAll(context: Rule.RuleContext, state: CollectListType): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseCodeType } from './type.js';
|
|
2
|
+
type LangFileType = Extract<BaseCodeType, 'json' | 'js' | 'ts'>;
|
|
3
|
+
export declare function getModifiedFiles(): Promise<string[]>;
|
|
4
|
+
export declare function readFile(filePath: string): Promise<string>;
|
|
5
|
+
export declare function getFileType(filePath: string): string;
|
|
6
|
+
export declare function writeFile(filePath: string, content: string): Promise<void>;
|
|
7
|
+
export declare function fileExists(filePath: string): Promise<boolean>;
|
|
8
|
+
export declare function writeI18nFile(filePath: string, content: Record<string, string>): Promise<void>;
|
|
9
|
+
export declare function getFileContent(filePath: string, fileType: LangFileType): Promise<{
|
|
10
|
+
exportPrefix: string;
|
|
11
|
+
code: any;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function isDescendant(file: string, dir: string): boolean;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Framework, I18nInfoType, KeyType, ReactCollectItemType, ReactI18nInfoType, TextNode } from './type.js';
|
|
2
|
+
import type { Rule } from 'eslint';
|
|
3
|
+
interface FileToI18nConfig<T extends Framework> {
|
|
4
|
+
type: T;
|
|
5
|
+
keyType?: KeyType;
|
|
6
|
+
i18nInfo: T extends 'vue' ? I18nInfoType : ReactI18nInfoType;
|
|
7
|
+
customIgnore?: (node: T extends 'vue' ? TextNode : ReactCollectItemType['textNode'], context: Rule.RuleContext) => boolean;
|
|
8
|
+
}
|
|
9
|
+
interface FileToI18nAndTranslateConfig<T extends Framework> extends FileToI18nConfig<T> {
|
|
10
|
+
lang: string[];
|
|
11
|
+
apiKey: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class I18nEasy {
|
|
14
|
+
/**
|
|
15
|
+
* vue框架中将文件内容转换成i18n写法并翻译
|
|
16
|
+
* @param filePath 文件绝对路径
|
|
17
|
+
* @param options 配置项
|
|
18
|
+
*/
|
|
19
|
+
private fileToI18nVue;
|
|
20
|
+
/**
|
|
21
|
+
* react框架中将文件内容转换成i18n写法并翻译
|
|
22
|
+
* @param filePath 文件绝对路径
|
|
23
|
+
* @param options 配置项
|
|
24
|
+
*/
|
|
25
|
+
private fileToI18nReact;
|
|
26
|
+
/**
|
|
27
|
+
* 将文件内容转换成i18n写法
|
|
28
|
+
* @param filePath 文件绝对路径
|
|
29
|
+
* @param options 配置项
|
|
30
|
+
*/
|
|
31
|
+
fileToI18n<T extends Framework>(filePath: string, options: FileToI18nConfig<T>): Promise<{
|
|
32
|
+
newFileContent: string;
|
|
33
|
+
fixed: boolean;
|
|
34
|
+
filePath: string;
|
|
35
|
+
oldFileContent: string;
|
|
36
|
+
keyValueMap: [string, string][];
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* 将文件内容转换成i18n写法并翻译
|
|
40
|
+
* @param filePath 文件绝对路径
|
|
41
|
+
* @param options 配置项
|
|
42
|
+
*/
|
|
43
|
+
fileToI18nAndTranslate<T extends Framework>(filePath: string, options: FileToI18nAndTranslateConfig<T>): Promise<{
|
|
44
|
+
translateResult: Record<string, Record<string, string>>;
|
|
45
|
+
newFileContent: string;
|
|
46
|
+
fixed: boolean;
|
|
47
|
+
filePath: string;
|
|
48
|
+
oldFileContent: string;
|
|
49
|
+
keyValueMap: [string, string][];
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* 将文件内容转换成i18n写法并翻译,支持批量
|
|
53
|
+
* @param filePath 文件绝对路径
|
|
54
|
+
* @param options 配置项
|
|
55
|
+
*/
|
|
56
|
+
fileToI18nAndTranslateBatch<T extends Framework>(filePaths: string[], options: FileToI18nAndTranslateConfig<T>): Promise<{
|
|
57
|
+
transformResult: {
|
|
58
|
+
newFileContent: string;
|
|
59
|
+
fixed: boolean;
|
|
60
|
+
filePath: string;
|
|
61
|
+
oldFileContent: string;
|
|
62
|
+
keyValueMap: [string, string][];
|
|
63
|
+
}[];
|
|
64
|
+
translateResult: Record<string, Record<string, string>>;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* @description 获取需要处理的文件信息
|
|
68
|
+
* @returns 文件信息
|
|
69
|
+
*/
|
|
70
|
+
private getPendingFiles;
|
|
71
|
+
/**
|
|
72
|
+
* @description 对git暂存区的文件进行i18n转换和翻译 并将翻译结果写入语言文件
|
|
73
|
+
* @returns {Promise<void>}
|
|
74
|
+
*/
|
|
75
|
+
transformModifiedFiles(): Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
export {};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { KeyType } from './type.js';
|
|
2
|
+
export default class KeyMap {
|
|
3
|
+
private charMap;
|
|
4
|
+
private keyType;
|
|
5
|
+
private static instance;
|
|
6
|
+
private constructor();
|
|
7
|
+
static getInstance(): KeyMap;
|
|
8
|
+
get charList(): Map<string, string>;
|
|
9
|
+
generateKey(str: string): string;
|
|
10
|
+
clearCharMap(): void;
|
|
11
|
+
setCharMap(key: string, value: string): void;
|
|
12
|
+
isEmpty(): boolean;
|
|
13
|
+
setKeyType(type: KeyType): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export default class Translate {
|
|
2
|
+
private endpoint;
|
|
3
|
+
private apiKey;
|
|
4
|
+
private static instance;
|
|
5
|
+
private constructor();
|
|
6
|
+
static getInstance(): Translate;
|
|
7
|
+
/**
|
|
8
|
+
* 构建微软翻译API请求配置
|
|
9
|
+
* @param originalTextArr 原始文本数组,每个元素为{ text: string }
|
|
10
|
+
* @param lang 目标语言数组
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
private buildRequestConfig;
|
|
14
|
+
/**
|
|
15
|
+
* 处理微软翻译API响应数据
|
|
16
|
+
* @param responseData 翻译API响应数据,每个元素为{ translations: { text: string }[] }
|
|
17
|
+
* @param originalTextArr 原始文本数组,每个元素为[ key: string, text: string ]
|
|
18
|
+
* @param lang 目标语言数组
|
|
19
|
+
* @returns 翻译结果,格式为{ language: { key: text } }
|
|
20
|
+
*/
|
|
21
|
+
private processResponse;
|
|
22
|
+
/**
|
|
23
|
+
* 翻译中文为其他指定语言
|
|
24
|
+
* @param originalTextArr 原始文本数组,每个元素为[ key: string, text: string ]
|
|
25
|
+
* @param lang 目标语言数组
|
|
26
|
+
* @returns 翻译结果,格式为{ language: { key: text } }
|
|
27
|
+
*/
|
|
28
|
+
translate(originalTextArr: [string, string][], lang: string[]): Promise<Record<string, Record<string, string>>>;
|
|
29
|
+
/**
|
|
30
|
+
* 设置微软翻译API密钥
|
|
31
|
+
* @param apiKey 微软翻译API密钥
|
|
32
|
+
*/
|
|
33
|
+
setApiKey(apiKey: string): void;
|
|
34
|
+
}
|
package/types/type.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { AST } from 'vue-eslint-parser';
|
|
2
|
+
import * as ESTree from 'estree';
|
|
3
|
+
import type { Rule } from 'eslint';
|
|
4
|
+
export type Framework = 'vue' | 'react';
|
|
5
|
+
export type BaseCodeType = 'vue' | 'js' | 'jsx' | 'ts' | 'tsx' | 'json' | 'template' | 'script' | 'scriptSetup';
|
|
6
|
+
export interface SupportFileMap {
|
|
7
|
+
vue: Extract<BaseCodeType, 'vue' | 'js' | 'jsx' | 'ts' | 'tsx'>;
|
|
8
|
+
react: Extract<BaseCodeType, 'js' | 'jsx' | 'ts' | 'tsx'>;
|
|
9
|
+
}
|
|
10
|
+
export interface I18nInfoType {
|
|
11
|
+
template?: {
|
|
12
|
+
callMethodName: string;
|
|
13
|
+
};
|
|
14
|
+
script?: {
|
|
15
|
+
callMethodName: string;
|
|
16
|
+
injectImport?: string;
|
|
17
|
+
injectCodeToTopLevel?: string;
|
|
18
|
+
};
|
|
19
|
+
scriptSetup?: {
|
|
20
|
+
callMethodName: string;
|
|
21
|
+
injectImport?: string;
|
|
22
|
+
injectCodeToTopLevel?: string;
|
|
23
|
+
injectHooksCall?: string;
|
|
24
|
+
};
|
|
25
|
+
js?: {
|
|
26
|
+
callMethodName: string;
|
|
27
|
+
injectImport?: string;
|
|
28
|
+
injectCodeToTopLevel?: string;
|
|
29
|
+
};
|
|
30
|
+
jsx?: {
|
|
31
|
+
callMethodName: string;
|
|
32
|
+
injectImport?: string;
|
|
33
|
+
injectCodeToTopLevel?: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface LangType {
|
|
37
|
+
name: string;
|
|
38
|
+
i18nFilePath: string;
|
|
39
|
+
}
|
|
40
|
+
export interface JSXText extends ESTree.BaseNode, ESTree.BaseExpression {
|
|
41
|
+
type: 'JSXText';
|
|
42
|
+
value: string;
|
|
43
|
+
raw: string | undefined;
|
|
44
|
+
}
|
|
45
|
+
export type TextNode = AST.VText | AST.VAttribute | ESTree.TemplateLiteral | (ESTree.Literal & Rule.NodeParentExtension) | JSXText;
|
|
46
|
+
export type TextNodeType = 'VText' | 'VAttribute' | 'TemplateLiteral' | 'Literal' | 'JSXText';
|
|
47
|
+
export type SetUpNode = ESTree.FunctionExpression | ESTree.ArrowFunctionExpression | ESTree.Program | null;
|
|
48
|
+
export type CodeType = Extract<BaseCodeType, 'js' | 'jsx' | 'script' | 'scriptSetup' | 'template'>;
|
|
49
|
+
interface CollectItemType {
|
|
50
|
+
textNode: TextNode;
|
|
51
|
+
codeType: Extract<BaseCodeType, 'js' | 'jsx' | 'script' | 'template'>;
|
|
52
|
+
setUpNode: SetUpNode;
|
|
53
|
+
inSetup: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface CollectListType {
|
|
56
|
+
templateTextNodeList: CollectItemType[];
|
|
57
|
+
scriptTextNodeList: CollectItemType[];
|
|
58
|
+
jsTextNodeList: CollectItemType[];
|
|
59
|
+
jsxTextNodeList: CollectItemType[];
|
|
60
|
+
}
|
|
61
|
+
export interface NodeListener extends Rule.NodeListener {
|
|
62
|
+
VText: (node: AST.VText) => void;
|
|
63
|
+
VAttribute: (node: AST.VAttribute) => void;
|
|
64
|
+
JSXText: (node: JSXText) => void;
|
|
65
|
+
[key: string]: ((...args: any[]) => void) | undefined;
|
|
66
|
+
}
|
|
67
|
+
export interface ReactCollectItemType {
|
|
68
|
+
textNode: ESTree.TemplateLiteral | (ESTree.Literal & Rule.NodeParentExtension) | JSXText;
|
|
69
|
+
componentNode: ESTree.FunctionDeclaration | ESTree.VariableDeclarator | null;
|
|
70
|
+
programNode: ESTree.Program | null;
|
|
71
|
+
inComp: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface ReactCollectListType {
|
|
74
|
+
inComponent: ReactCollectItemType[];
|
|
75
|
+
outComponent: ReactCollectItemType[];
|
|
76
|
+
}
|
|
77
|
+
export type ReactInjectCodeType = ESTree.FunctionDeclaration | ESTree.VariableDeclarator | ESTree.Program;
|
|
78
|
+
export interface ReactI18nInfoType {
|
|
79
|
+
js?: {
|
|
80
|
+
callMethodName: string;
|
|
81
|
+
injectImport?: string;
|
|
82
|
+
injectCodeToTopLevel?: string;
|
|
83
|
+
};
|
|
84
|
+
jsx?: {
|
|
85
|
+
callMethodName: string;
|
|
86
|
+
injectImport?: string;
|
|
87
|
+
injectCodeToTopLevel?: string;
|
|
88
|
+
injectHooksCall?: string;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export type ReactCodeType = Extract<BaseCodeType, 'js' | 'jsx'>;
|
|
92
|
+
export type LogStatus = 'success' | 'info' | 'fail';
|
|
93
|
+
export type KeyType = 'hash' | 'pinyin' | 'pinyinWithNumber';
|
|
94
|
+
export {};
|
package/types/utils.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Framework, SupportFileMap, KeyType, LangType, I18nInfoType, ReactI18nInfoType, TextNode, ReactCollectItemType } from './type.js';
|
|
2
|
+
import type { Rule } from 'eslint';
|
|
3
|
+
export interface Config<T extends Framework> {
|
|
4
|
+
projects: {
|
|
5
|
+
projectPath: string;
|
|
6
|
+
lang: LangType[];
|
|
7
|
+
i18nInfo: T extends 'vue' ? I18nInfoType : ReactI18nInfoType;
|
|
8
|
+
keyType: KeyType;
|
|
9
|
+
type: T;
|
|
10
|
+
customIgnore?: (node: T extends 'vue' ? TextNode : ReactCollectItemType['textNode'], context: Rule.RuleContext) => boolean;
|
|
11
|
+
}[];
|
|
12
|
+
apiKey: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @description 判断字符串是否包含中文
|
|
16
|
+
* @param str 字符串
|
|
17
|
+
* @returns {boolean} 是否包含中文
|
|
18
|
+
*/
|
|
19
|
+
export declare function hasChineseChar(str: string | undefined | null): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @description 生成对应字符串的 hash 值或拼音值
|
|
22
|
+
* @param char 字符串
|
|
23
|
+
* @param keyType 键类型
|
|
24
|
+
* @returns {string} hash 值或拼音值
|
|
25
|
+
*/
|
|
26
|
+
export declare function generateKeyByKeyType(char: string, keyType: KeyType): string;
|
|
27
|
+
/**
|
|
28
|
+
* @description 判断是否为vue文件的script src导入
|
|
29
|
+
* @param filePath 文件路径
|
|
30
|
+
* @param fileType 文件类型
|
|
31
|
+
* @returns {Promise<boolean>} 是否为vue文件的script src导入
|
|
32
|
+
*/
|
|
33
|
+
export declare function isVueScriptSrcImport(filePath: string, fileType: string): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* @description 判断文件类型是否支持转换
|
|
36
|
+
* @param fileType 文件类型
|
|
37
|
+
* @param framework 框架类型
|
|
38
|
+
* @returns {boolean} 是否支持转换
|
|
39
|
+
*/
|
|
40
|
+
export declare function isSupportFileType<F extends Framework>(fileType: string, framework: F): fileType is SupportFileMap[F];
|
|
41
|
+
/**
|
|
42
|
+
* @description 在指定目录下查重指定名称文件,并加载文件导出内容
|
|
43
|
+
* @param dirPath 目录路径
|
|
44
|
+
* @param searchPlaces 文件名称列表
|
|
45
|
+
* @returns {Promise<any | null>} 文件内容
|
|
46
|
+
*/
|
|
47
|
+
export declare function searchFileContent<T extends Framework>(dirPath: string, searchPlaces: string[]): Promise<Config<T> | null>;
|
|
48
|
+
/**
|
|
49
|
+
* @description 配置辅助函数
|
|
50
|
+
* @param config 配置项
|
|
51
|
+
* @returns 配置项
|
|
52
|
+
*/
|
|
53
|
+
export declare function defineConfig<T extends Framework>(config: Config<T>): Config<T>;
|
|
54
|
+
export declare function customTranslation(source: string, translation: string): string;
|