Skip to content

Comments

Fixing UI Translation Service Issue#68

Merged
nniknam1 merged 6 commits intomainfrom
fixining-translation-button
Nov 18, 2025
Merged

Fixing UI Translation Service Issue#68
nniknam1 merged 6 commits intomainfrom
fixining-translation-button

Conversation

@nniknam1
Copy link

Tool Description

This PR integrates automatic LLM-based translation into NodeBB.
When a user posts a message in a non-English language, NodeBB detects this and sends the content to a remote translation service running on a GPU VM. The service uses a Flask-based API backed by an Ollama LLM to produce a high-quality English translation. The final UI displays the translated message directly underneath the original post in a clear, styled info panel.

This feature improves accessibility, cross-language communication, and supports mixed-language communities without modifying the core posting flow.

How it works:
NodeBB → GPU VM:

  1. NodeBB sends POST /translate with the post content.

  2. GPU VM responds with:

    { "is_english": false, "translated_content": "" }
  3. Non-English posts are annotated with the translation and rendered in the UI.


Changes Made

Backend Integration (UI VM – NodeBB)

  • Implemented remote translation pipeline in src/translate/index.js.

    • Calls GPU VM endpoint: http://crs-17313-nodegpt-gpu.qatar.cmu.edu/translate.

    • Added try/catch to prevent “fetch failed” from crashing the site.

    • Ensures the output matches NodeBB’s expected data structure:

      [isEnglish, translatedContent]
  • Attached translation fields to post data:

    • posts.isEnglish
    • posts.translatedContent
  • Updated post creation logic to correctly store translated content in post metadata.

UI Rendering (Frontend)

  • Modified public/templates/partials/topic/post.tpl to show translations directly for non-English posts.

  • Final UI (no toggle/button):

    • Displays a blue info box under the original content:
      “Translated message: ”
  • Ensures visibility only when posts.isEnglish === false.

GPU VM Translation Service (Remote)

(Not part of this repository but required for full functionality)

  • Deployed Flask + Ollama translation microservice.
  • Nginx reverse proxy (/translate) configured for external access.
  • Verified correct integration between UI VM and GPU VM.

Evidence of Successful Integration

Backend Logs (UI VM)

NodeBB logs confirm successful translation and data flow:

LLM translate debug: {
  original: 'Die ist eine Nachricht auf Deutsch',
  isEnglish: false,
  translated: 'This is a message in German'
}

UI Output

For a German post:

Translated message: This is a message in German

Screenshot 2025-11-18 023043

End-to-End Verification

  • Posting non-English text triggers translation request to GPU VM.
  • GPU VM returns accurate English translation.
  • NodeBB renders translated content automatically.
  • English posts remain unchanged.
  • No errors, crashes, or bad gateway responses.

Files Modified

  • src/translate/index.js
  • public/templates/partials/topic/post.tpl
  • public/src/client/topic.js (light cleanup to remove unused button logic)

Summary

This PR delivers full multilingual support by integrating NodeBB with a GPU-accelerated LLM translation service. The solution is resilient, production-safe, and improves user experience by showing translations directly in the UI without additional interaction.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 19448429339

Details

  • 6 of 17 (35.29%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.03%) to 78.477%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/translate/index.js 6 17 35.29%
Files with Coverage Reduction New Missed Lines %
src/translate/index.js 1 30.43%
Totals Coverage Status
Change from base Build 19390469716: -0.03%
Covered Lines: 24807
Relevant Lines: 29756

💛 - Coveralls

@nniknam1 nniknam1 marked this pull request as ready for review November 17, 2025 23:50
Copy link

@FaizFarooqMoazam FaizFarooqMoazam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link

@dkhalifa25 dkhalifa25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@nniknam1 nniknam1 merged commit 387ea56 into main Nov 18, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants