You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
import {TextTranslateResponse} from "tencentcloud-sdk-nodejs/tencentcloud/services/tmt/v20180321/tmt_models";
|
|
|
|
const tencentcloud = require("tencentcloud-sdk-nodejs")
|
|
|
|
const TmtClient = tencentcloud.tmt.v20180321.Client;
|
|
|
|
const clientConfig = {
|
|
credential: {
|
|
secretId: process.env.REACT_APP_TENCENT_SECRET_ID,
|
|
secretKey: process.env.REACT_APP_TENCENT_SECRET_KEY,
|
|
},
|
|
region: process.env.REACT_APP_TENCENT_REGION,
|
|
profile: {
|
|
httpProfile: {
|
|
endpoint: process.env.REACT_APP_TENCENT_ENDPOINT,
|
|
},
|
|
},
|
|
};
|
|
|
|
const client = new TmtClient(clientConfig)
|
|
export default function tencentTmt(SourceText:string,Target:string){
|
|
return new Promise((resolve:(value:TextTranslateResponse)=>void, reject) => {
|
|
const params = {
|
|
SourceText,
|
|
"Source": "auto",
|
|
Target,
|
|
"ProjectId": 0
|
|
};
|
|
client.TextTranslate(params).then(
|
|
(res:TextTranslateResponse) => {
|
|
resolve(res)
|
|
},
|
|
(err: any) => {
|
|
reject(err)
|
|
}
|
|
)
|
|
})
|
|
|
|
|
|
} |