Add On-Demand Translation for Comments on Game Profiles, User Profiles, etc... #851
Labels
No labels
automated
code-quality
component: admin dashboard
component: backend
component: billing
component: content management
component: faqs
component: game genres
component: game lists
component: game reviews
component: game search
component: games
component: internal notifications
component: platforms
component: security
component: tests
component: user api
component: user badges
component: user blogs
component: user consoles
component: user favorites
component: user friends
component: user notifications
component: user profiles
component: user site notifications
component: user wishlists
component: web design
dependencies
javascript
php
priority
high
priority
low
priority
medium
security-hotspot
source: codex
source: sonarqube
status
awaiting feedback
status
backlog
status
done
status
in progress
status
in queue
status
in review
status
needs codex review
status
needs investigation
status
wontfix
type: bug
type: documentation
type: feature
type: improvement
type: regression
type: task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MyVideoGameList/myvideogamelist.com#851
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add on-demand English translation for non-English user-generated Moments and comments on game pages.
The idea was triggered by a non-English comment on:
https://myvideogamelist.com/game/8/hitman-blood-money
The first version should show a small
Translateaction beneath eligible Moments and comments. Original content remains visible by default. When a signed-in user clicksTranslate, the browser asks the MyVideoGameList backend for an English translation, displays the translated text beneath the original, and shows the detected source language when available.Example behavior
Original Russian comment remains visible.
Translated from Russian · Hide translationUsers should be able to hide and show an already loaded translation again without triggering another API request.
Initial scope
Out of scope for the first version:
Provider abstraction
Use DeepL first, but keep provider-specific code isolated behind an interface so providers such as LibreTranslate, OpenAI, Google Cloud Translation, or Kagi can be added later.
Suggested interface:
TranslationResultshould include:Use DeepL automatic source-language detection. Store the detected language code with the cached translation and map known codes to readable names, such as
RUtoRussian,JAtoJapanese, andDEtoGerman.If the source language cannot be determined, display
Translated to English.Do not make a separate language-detection request just to decide whether the
Translatebutton should be displayed. For the first version, it is acceptable to showTranslateon all eligible content and let the backend determine whether translation is necessary.Configuration
Suggested environment variables:
The DeepL API key must remain server-side and must never be exposed to browser JavaScript.
Backend endpoint
Create a protected backend translation endpoint.
Suggested request:
The browser should send only the content type and database ID. The backend must load the authoritative source content from the database.
The endpoint must not accept arbitrary text from the browser and forward it to the translation provider, because that would allow abuse as a general-purpose translation proxy.
A successful response should include:
Translation cache
Cache translations in the database so the same unchanged content is not translated repeatedly.
Suggested table:
content_translationsFields:
idcontent_typecontent_idsource_languagetarget_languagetranslated_textprovideroriginal_text_hashcreated_atupdated_atAdd a unique constraint for content type, content ID, and target language.
Before calling the provider:
If a Moment or comment is edited, the old cached translation must no longer be treated as valid.
Abuse and security protections
Preserve paragraph breaks where possible. Treat provider output as untrusted text. Do not render provider-returned HTML directly.
Error handling
Handle these states safely:
Use a generic user-facing message such as:
Do not expose stack traces, API responses, credentials, or internal error details.
Logging and metrics
Log translation failures through the application's existing logging system.
Include:
Do not log API keys, authorization headers, or full private content unnecessarily.
Track basic usage metrics if practical:
This matters because the initial DeepL Developer allowance is a one-time pool of 1 million characters.
Accessibility
aria-busyor an equivalent.Suggested implementation order
TranslateUI to Moments and comments.Tests
Provider layer:
Caching:
Endpoint:
Frontend:
Acceptance criteria
Translatebeneath an eligible Moment or comment.Add on-demand translation for Moments and commentsto Add On-Demand Translation for Comments on Game Profiles, User Profiles, etc...