UNPKG

i18n-auto-react

Version:

基于百度翻译API服务的自动翻译插件

32 lines (29 loc) 1 kB
import { d as getConfiguration } from '../utils/index.js'; import { G as GenExport } from './GenExport.js'; import { I as Init } from './Init.js'; import { T as Translate } from './Translate.js'; import { l as logger } from '../utils/log.js'; class I18nCommand { command; constructor(command) { this.command = command; } run() { let config = this.command == 'init' ? {} : getConfiguration(); const commandMap = { init: new Init(), translate: new Translate(config), genExport: new GenExport(config) }; let command = commandMap[this.command]; if (!command) { logger.error(`${this.command} 命令不存在`); logger.info('npx i18n init: 初始化配置文件'); logger.info('npx i18n translate: 生成语言包'); logger.info('npx i18n genExport: 生成导出文件'); return; } command.run(); } } export { I18nCommand };