Skip to content

Commit

Permalink
Fixed bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ay0503 committed Nov 15, 2024
1 parent 4d30379 commit 5a48033
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/posts/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function (Posts) {
const content = data.content.toString();
const timestamp = data.timestamp || Date.now();
const isMain = data.isMain || false;
const [isEnglish, translatedContent] = await translate.translate(data)
const [isEnglish, translatedContent] = await translate.translate(data);

if (!uid && parseInt(uid, 10) !== 0) {
throw new Error('[[error:invalid-uid]]');
Expand Down
4 changes: 3 additions & 1 deletion src/translate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const translatorApi = module.exports;
translatorApi.translate = async function (postData) {
// Edit the translator URL below
const TRANSLATOR_API = "https://nodebb-f24-translator.azurewebsites.net"
const response = await fetch(TRANSLATOR_API + '/?content=' + postData.content);
const query = `?content=${postData.content}`;
const url = encodeURI(TRANSLATOR_API + '/' + query);
const response = await fetch(url);
const data = await response.json();
return [data["is_english"], data["translated_content"]]
}

0 comments on commit 5a48033

Please sign in to comment.