From 63e72374a4c5931d7393f522a236d0b8112807b4 Mon Sep 17 00:00:00 2001 From: Anna Shi Date: Wed, 13 Nov 2024 06:04:04 +0000 Subject: [PATCH 1/3] added translate fields to posts for api --- .gitignore | 2 ++ .mocharc.yml | 2 +- dump.rdb | Bin 47205 -> 0 bytes .../openapi/components/schemas/PostObject.yaml | 4 ++++ public/openapi/write/posts/pid.yaml | 4 ++++ src/{ => translate}/translator.js | 4 ++-- 6 files changed, 13 insertions(+), 3 deletions(-) delete mode 100644 dump.rdb rename src/{ => translate}/translator.js (54%) diff --git a/.gitignore b/.gitignore index 42a1b3c705..7db726beb8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +dump.rdb + dist/ yarn.lock npm-debug.log diff --git a/.mocharc.yml b/.mocharc.yml index 16d8518d1b..b9246aa609 100644 --- a/.mocharc.yml +++ b/.mocharc.yml @@ -1,4 +1,4 @@ reporter: dot timeout: 25000 exit: true -bail: true +bail: false diff --git a/dump.rdb b/dump.rdb deleted file mode 100644 index cb7e290355e867e743a04f5d40b0134a49b579d5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 47205 zcmdUY349w@o$wo7w&hFm?Zk=3vJ)S%d?rpJLU&~6Y?C%LX}hIqq>(hXmFPkv#c{dR zB+Y#%r44PtJt$BXmR)wcz*1JNzx|fIzP(s>7YdyoK%pEhH4E(m`Tp;{8EG^b$#zPc zF8L{;nt7Tx|M$Pon>VcAvZKF$VBpQNgb)mgu6;tnyt;R=ch#F#`h`D~6f@kL=0GwO z5uT~5{rT9Nr72Mex*|g48LoB-db5;|jk)~1C}hy@(Eo5hVC?L8B9@A~`Cudz4T;GF zpNu6$H!ScA33ogc6l-e{LI%VzvmfjFUj2Cnp|Z>N7P<;{5E=`?1K=syRjL(7ax1#& zia;pnUg?e}Li<8tVO$X1zkUqpdi+=uH zyp0l6cAD&(T~bPST|LWWn#<2^3dj6>nB5i&3h5R@&8#8QQg(PeC5TC}WY(Cm8;^+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**51gvT1^okb^xaD1#-EXW;gQso|E0wg@p(E<%XQk2@16jtJ zOL5yuJuB7M&6+ull}h4s?6tO1)%CV|emdFyCgD@XoAcH)j&+BF49{>M;U1`d0IXuw z2+VP|bWvPXjliVkxb6v1XoN)XToW*lj`7IlTW&5ph6}#Zbvn~8ZzoehLPiUu)2RnG zX(E^^4>VS^lN(jzlyDDFxktloUHU3ak{CiWeWSfmFVIO_kF!mF3rN?)iOB7 zQmk5rj(WT1)iQOt_GE6kJ)(PPhWjvg(Q#3YCinDVzmkPckFk6V505F2`C-_kj3rzP z43B9%BL76`Av{{sd<=I<9EIE=(Ru`93D<5eJUgcPR)Qr#qs0hVGDuxJ*!7|Td%iar zdM0G?}Gfo+8D3d-5ub7e}!pvvR~=i?}WK&Z!@m#pgN6^9urL82zoOALatM zHGe0$nv)hjnFUo-U){;rmr|Ba`;+1(8Z@g$L5Cc}{9tZ?u!>D+QUTRs07MgZ+w0^= zX%-dES5bAG(92h$m5kRqUqy}F8U{$fLHHl_3*)4Sxg$WO*=5t^<{V<<;%6DLx$f!m zn)c%~#6d$CzYn##5YJoyUJvIq1U*=&tNCz4Kn2a_H}A<#88QyV$+JCk=$R{XQ22Ji zh@GBxwQ`2LTRVsTXkR=QPlfqJnXF)4x}yp-EVY6)?EnR9QBeiU3jHAyLSYT7hU(#a zj208f=SI~ls#{#@zNjj5UBe#<22u9DK&5>_or?6to;vA6Io>%s6)jlq(U83=H?i>R zE7rq2w{o?aGt^L|$@samQWfl~HmhNOsZ diff --git a/public/openapi/components/schemas/PostObject.yaml b/public/openapi/components/schemas/PostObject.yaml index 78e53d85d4..446c01689d 100644 --- a/public/openapi/components/schemas/PostObject.yaml +++ b/public/openapi/components/schemas/PostObject.yaml @@ -9,6 +9,10 @@ PostObject: description: A topic identifier content: type: string + isEnglish: + type: boolean + translatedContent: + type: string uid: type: number description: A user identifier diff --git a/public/openapi/write/posts/pid.yaml b/public/openapi/write/posts/pid.yaml index d538000827..b993c1da34 100644 --- a/public/openapi/write/posts/pid.yaml +++ b/public/openapi/write/posts/pid.yaml @@ -66,6 +66,10 @@ get: type: boolean downvoted: type: boolean + isEnglish: + type: boolean + translatedContent: + type: string put: tags: - posts diff --git a/src/translator.js b/src/translate/translator.js similarity index 54% rename from src/translator.js rename to src/translate/translator.js index 8584686056..06102a7350 100644 --- a/src/translator.js +++ b/src/translate/translator.js @@ -8,7 +8,7 @@ function warn(msg) { } } -module.exports = require('../public/src/modules/translator.common')(require('./utils'), (lang, namespace) => { - const languages = require('./languages'); +module.exports = require('../../public/src/modules/translator.common')(require('../utils'), (lang, namespace) => { + const languages = require('../languages'); return languages.get(lang, namespace); }, warn); From bcb88301a291d8fb21d3b1a55a3b240bec7d6ac3 Mon Sep 17 00:00:00 2001 From: Anna Shi Date: Wed, 13 Nov 2024 20:34:43 +0000 Subject: [PATCH 2/3] moved around translator files --- src/{translate => }/translator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/{translate => }/translator.js (54%) diff --git a/src/translate/translator.js b/src/translator.js similarity index 54% rename from src/translate/translator.js rename to src/translator.js index 06102a7350..8584686056 100644 --- a/src/translate/translator.js +++ b/src/translator.js @@ -8,7 +8,7 @@ function warn(msg) { } } -module.exports = require('../../public/src/modules/translator.common')(require('../utils'), (lang, namespace) => { - const languages = require('../languages'); +module.exports = require('../public/src/modules/translator.common')(require('./utils'), (lang, namespace) => { + const languages = require('./languages'); return languages.get(lang, namespace); }, warn); From c916b09068f26ddd4957e94013f001810150dee4 Mon Sep 17 00:00:00 2001 From: vickyc2266 <146585559+vickyc2266@users.noreply.github.com> Date: Wed, 13 Nov 2024 18:26:14 -0500 Subject: [PATCH 3/3] got the frontend to work and translate --- public/src/client/topic.js | 15 +++++++++++++++ src/posts/create.js | 4 ++++ src/posts/data.js | 2 ++ src/translate/index.js | 13 +++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 src/translate/index.js diff --git a/public/src/client/topic.js b/public/src/client/topic.js index 7e65cbeb4f..8667b1d361 100644 --- a/public/src/client/topic.js +++ b/public/src/client/topic.js @@ -71,12 +71,27 @@ define('forum/topic', [ handleThumbs(); $(window).on('scroll', utils.debounce(updateTopicTitle, 250)); + configurePostToggle(); handleTopicSearch(); hooks.fire('action:topic.loaded', ajaxify.data); }; + function configurePostToggle() { + $('.topic').on('click', '.view-translated-btn', function () { + // Toggle the visibility of the next .translated-content div + $(this).closest('.sensitive-content-message').next('.translated-content').toggle(); + // Optionally, change the button text based on visibility + var isVisible = $(this).closest('.sensitive-content-message').next('.translated-content').is(':visible'); + if (isVisible) { + $(this).text('Hide the translated message.'); + } else { + $(this).text('Click here to view the translated message.'); + } + }); + } + function handleTopicSearch() { require(['mousetrap'], (mousetrap) => { if (config.topicSearchEnabled) { diff --git a/src/posts/create.js b/src/posts/create.js index c035f86013..be9070d44c 100644 --- a/src/posts/create.js +++ b/src/posts/create.js @@ -10,6 +10,7 @@ const topics = require('../topics'); const categories = require('../categories'); const groups = require('../groups'); const privileges = require('../privileges'); +const translate = require('../translate'); module.exports = function (Posts) { Posts.create = async function (data) { @@ -20,6 +21,7 @@ module.exports = function (Posts) { const timestamp = data.timestamp || Date.now(); const isMain = data.isMain || false; const endorsed = data.endorsed || false; + const [isEnglish, translatedContent] = await translate.translate(data); if (!uid && parseInt(uid, 10) !== 0) { throw new Error('[[error:invalid-uid]]'); @@ -37,6 +39,8 @@ module.exports = function (Posts) { content: content, timestamp: timestamp, endorsed: endorsed, + translatedContent: translatedContent, + isEnglish: isEnglish, }; if (data.toPid) { diff --git a/src/posts/data.js b/src/posts/data.js index 99d551fdf8..6e14166d86 100644 --- a/src/posts/data.js +++ b/src/posts/data.js @@ -71,5 +71,7 @@ function modifyPost(post, fields) { if (post.hasOwnProperty('endorsed')) { post.endorsed = post.endorsed ? post.endorsed : false; } + // Mark post as "English" if decided by translator service or if it has no info + post.isEnglish = post.isEnglish === 'true' || post.isEnglish === undefined; } } diff --git a/src/translate/index.js b/src/translate/index.js new file mode 100644 index 0000000000..4c8a414123 --- /dev/null +++ b/src/translate/index.js @@ -0,0 +1,13 @@ +'use strict'; + +// const request = require('request'); + +const translatorApi = module.exports; + +translatorApi.translate = async function (postData) { + // Edit the translator URL below + const TRANSLATOR_API = 'https://nodebb-boba-translator.azurewebsites.net/'; + const response = await fetch(`${TRANSLATOR_API}/?content=${postData.content}`); + const data = await response.json(); + return [data.is_english, data.translated_content]; +};