Subtranslate

Repository: github.com/jprimeai/reddit-mod-app-subtranslate

Developed by JPrime.

Inspiration

Moderating multilingual subreddits is hard. When a post or comment arrives in a language the mod team does not speak, reviewers often copy text into external translation tools, switch tabs, and lose context. That workflow is slow, inconsistent, and easy to skip under pressure.

We built Subtranslate to bring translation directly into the moderator workflow on Reddit — one click from the post or comment menu, no tab switching, no copy-paste.

What it does

Subtranslate is a Devvit mod tool that translates Reddit posts and comments with AI.

Moderators open the ⋮ menu on a post or comment, choose Translate, and get a review form showing the original text alongside the translation. Each subreddit configures its own AI provider, model, API key, and target language on the app install settings page.

The app supports OpenAI and Google Gemini, and caches translations in Redis keyed by a hash of the original content plus translation settings. If the same content is translated again with the same configuration, the cached result is returned instantly with no additional API token usage.

How we built it

Subtranslate is a server-only Devvit Web app — no custom post UI, no client bundle. The stack:

  • Devvit Web — runs on Reddit's serverless platform with moderator-scoped Reddit API access
  • Hono — lightweight HTTP server for internal menu and form endpoints
  • TypeScript — end-to-end type safety across server and shared modules
  • Vite — builds the server bundle via @devvit/start
  • Redis — stores translation cache entries per installation
  • OpenAI / Gemini APIs — handles the actual translation

The architecture is intentionally minimal:

Menu action → read post/comment text → check Redis cache → call AI (on miss) → show review form

Key modules:

  • src/server/routes/menu.ts — handles the Translate menu action and returns a review form
  • src/server/core/content.ts — reads post title/body or comment text from Devvit context
  • src/server/core/translate.ts — calls OpenAI or Gemini with a moderation-focused prompt
  • src/server/core/cache.ts — SHA-256 cache keys over content + provider + model + target language
  • src/server/core/settings.ts — loads per-subreddit install settings

Configuration lives in devvit.json: menu items, form mappings, permissions, and subreddit settings schema.

Challenges we ran into

Devvit permission defaults for server-only apps. Server-only apps without a post section do not automatically get the Reddit API enabled. We had to explicitly set permissions.reddit.enable: true — without it, menu actions failed when reading post or comment content.

Settings scope and secrets. Devvit treats global secrets differently from subreddit install settings. We wanted moderators to configure their own API key per subreddit on the install settings page, which meant using subreddit-scoped settings rather than CLI-only global secrets.

Platform constraints. Devvit Web has specific rules around what runs where — no window.alert, no file downloads, server endpoints must live under /internal/. We stripped out the original React template and rebuilt the app as a focused mod tool to stay within those boundaries.

Token cost on repeat translations. Moderators may translate the same viral post or comment multiple times. We added Redis caching with content hashing so identical requests reuse stored translations instead of calling the AI API again.

Accomplishments that we're proud of

  • A zero-context-switch translation flow that lives entirely inside Reddit's mod menu
  • Provider flexibility — subreddit admins choose OpenAI or Gemini and configure model and target language independently
  • Smart caching that cuts repeat API costs without changing the moderator experience
  • A lean codebase — server-only, no unused client UI, focused on one job done well
  • Shipping a working mod tool on Reddit's Devvit platform from template to production-ready app

What we learned

  • Devvit Web mod tools are a strong fit for moderator workflows that need server-side logic and Reddit API access without building a full custom post experience
  • Per-subreddit configuration via install settings gives communities control over provider, model, and language without redeploying the app
  • Caching by content hash is a simple, effective pattern for AI-powered tools where the same input is requested repeatedly
  • Explicit permission declarations matter on Devvit — assumptions about defaults do not always hold for server-only app shapes

What's next for Subtranslate

  • Comment menu support — extend the menu item to comments in addition to posts (the server already reads comment context)
  • Post translation as a reply — let moderators post the reviewed translation directly as a comment reply
  • Cache management — optional TTL or manual cache invalidation when subreddit settings change
  • More providers — support additional AI backends as Devvit HTTP allow-listing permits
  • Translation quality options — tone presets (formal, literal, community-friendly) for different moderation contexts
Share this project:

Updates