2024-09-18 16:58:59 +08:00

32 lines
916 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import RuleInterface from "./RuleInterface";
import FileObj from "../../vo/FileObj";
import * as TranslateUtil from "../../../util/TranslateUtil";
import path from 'path';
export default class TranslateRole implements RuleInterface {
/**
* 1:简体转繁体 2繁体转简体
*/
type: number;
/**
* 0、繁体中文1、港澳繁体2、台湾正体
*/
traditionalType: number;
constructor(data: any) {
this.type = data.type;
this.traditionalType = data.traditionalType;
}
deal(file: FileObj): void {
if (this.type == 1) {
file.realName = TranslateUtil.toTraditionalChinese(file.realName, this.traditionalType);
} else if (this.type == 2) {
file.realName = TranslateUtil.toSimplifiedChinese(file.realName, this.traditionalType);
}
file.name = file.realName + file.expandName;
}
}