基于 Nestjs 封装的翻译 API,目前支持百度翻译和有道翻译,持续更新中。
导入模块:
import { TranslateBaiduModule } from 'nest-translate'
@Module({
imports: [
TranslateBaiduModule.forRoot({ appid: '', secret: '' })
]
})
使用:
import { TranslateBaiduService } from 'nest-translate'
@Injectable()
export class UserService {
constructor(private readonly translateBaiduService: TranslateBaiduService) {}
}
当成工具类使用:
import { TranslateBaiduService } from 'nest-translate'
const translate = new TranslateBaiduService({ appid: '', secret: '' })