Skip to content

Commit

Permalink
Replace the translate function with translator API.
Browse files Browse the repository at this point in the history
  • Loading branch information
aoli-al committed Mar 19, 2024
1 parent 99154e4 commit 86490d3
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/translate/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
const { GoogleGenerativeAI } = require("@google/generative-ai");
var request = require('request')

const translatorApi = module.exports;

translatorApi.translate = async function (postData) {
if (postData.content == "你好") {
return [false, "hello"];
}
if (postData.content == "Bonjour") {
return [false, "hello"];
}
if (postData.content == "Hola") {
return [false, "hello"];
}
if (postData.content == "Olá") {
return [false, "hello"];
}
// ...
return [true, null];
const response = await fetch(process.env.TRANSLATOR_API+'/?content='+postData.content);
const data = await response.json();
return [data["is_english"], data["translated_content"]]
}

0 comments on commit 86490d3

Please sign in to comment.