feat: restore and complete LLM translation feature#70
Merged
Conversation
cirex-web
reviewed
Apr 2, 2026
cirex-web
reviewed
Apr 2, 2026
| const savedTid = tid; | ||
| translate.translate(postData).then(([isEng, transContent]) => { | ||
| Posts.setPostFields(savedPid, { isEnglish: isEng, translatedContent: transContent, isTranslating: false }); | ||
| const websockets = require('../socket.io'); |
There was a problem hiding this comment.
ah why is this require statement nested in several functions instead of being imported top-level?
Author
There was a problem hiding this comment.
Ah thank you for the catch! Will move it to the top and commit.
cirex-web
reviewed
Apr 2, 2026
| }); | ||
| } | ||
| }).catch(() => { | ||
| Posts.setPostFields(savedPid, { isEnglish: 'true', translatedContent: '', isTranslating: false }); |
cirex-web
approved these changes
Apr 2, 2026
There was a problem hiding this comment.
Looks good to me!
I just tweaked the translate function to use nconf.get('llm_endpoint') before falling back to localhost. (given that's where all the other configuration variables live, rather than process.env)
Also now the loading icon shows up right after you reply (without needing a refresh)
cirex-web
reviewed
Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Restores and completes the translation feature that was disabled in PR #69.
Changes
llm/app.py+llm/Dockerfile— Flask microservice calling Ollama qwen2.5:7b for language detection and translationsrc/translate/index.js— Restored async fetch-based translation (uses TRANSLATOR_URL env var instead of hardcoded URL)src/posts/create.js— Non-blocking post creation; translation runs as fire-and-forget background promisesrc/posts/data.js— PreservesisEnglish: 'loading'state and addsisTranslatingboolean coercionvendor/.../post.tpl— Three-state UI: spinner while translating, toggle button when done, nothing if Englishpublic/src/client/topic/events.js— Socket handler forevent:post.translatedto update DOM in real-timetest/translate.js— 5 mock tests for translate module (no real network calls)Testing
npx mocha test/translate.jsnpm run test