惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
博客园 - 【当耐特】
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
G
Google Developers Blog
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
P
Proofpoint News Feed
J
Java Code Geeks
U
Unit 42
云风的 BLOG
云风的 BLOG
阮一峰的网络日志
阮一峰的网络日志
N
Netflix TechBlog - Medium
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
Docker
V
Visual Studio Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
V
V2EX
T
Tailwind CSS Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Building a Multilingual News App with AI Translation
siddharth hariramani · 2026-06-22 · via DEV Community

siddharth hariramani

Building a Multilingual News App with AI Translation

Creating a news aggregator that works seamlessly across languages is more than a UI challenge—it’s a data pipeline problem. In this article I’ll walk through the core decisions, the tech stack, and a few gotchas I hit while building a production‑ready multilingual news app powered by AI translation.

Why AI Translation?

Traditional localization (static .po files, manual translation) works for fixed UI strings but falls apart when the content is dynamic and high‑volume—think RSS feeds, social media links, or user‑generated articles. Modern neural machine translation (NMT) services provide:

  • Near‑real‑time translation with context‑aware quality.
  • Support for dozens of languages out of the box.
  • Pay‑as‑you‑go pricing that scales with traffic.

Architecture Overview

┌─────────────┐        ┌───────────────┐
│ Front‑end   │ ↆ API │ Translation   │
│ (React/Vue) │──────►│ Service (e.g.,│
└─────▲───────┘        │ Google, Azure│
      │                └─────▲───────┘
      │                      │
      │            ┌─────────┴─────────┐
      │            │  Content Service  │
      │            │  (Node/Express)   │
      │            └───────▲───────────┘
      │                    │
      │            ┌───────┴───────┐
      │            │  DB (Mongo)  │
      │            └──────────────┘

  1. Fetcher pulls raw articles from RSS/JSON endpoints.
  2. Translator sends the article body (and optionally the title) to an NMT API.
  3. Cache layer stores the original and translated versions to avoid redundant calls.
  4. Frontend requests the language‑specific version via a GraphQL query.

Choosing the Translation API

I evaluated three major providers:

Provider Languages Avg. Latency Cost (per 1M chars)
Google Cloud Translation 100+ ~150 ms $20
Azure Translator 70+ ~120 ms $15
OpenAI Whisper + GPT‑4 (custom) 30+ (via prompts) >300 ms $40

For a news app targeting Indian users, Azure Translator gave the best balance of latency and cost, and it supports all major Indian languages (Hindi, Bengali, Tamil, Telugu, Marathi).

Tip: Enable “Glossary” or “Custom Translation” to improve domain‑specific terms (e.g., political party names).

Handling Multilingual Content

1. Normalizing the Input

function cleanHTML(html) {
  return html.replace(/<[^>]+>/g, '').trim();
}

Strip HTML tags before sending text to the translator; most APIs expect plain text.

2. Storing Translations

const ArticleSchema = new mongoose.Schema({
  sourceId: String,
  title: { en: String, hi: String, ta: String, te: String, mr: String },
  body:   { en: String, hi: String, ta: String, te: String, mr: String },
  publishedAt: Date,
});

Using a nested object per language keeps reads simple (article.title[lang]).

3. Fallback Logic

If a translation fails or is delayed, fall back to the original English version and show a small “Translate” button that triggers an on‑demand request.

Performance & Caching

  • Redis: Cache the translation result for 24 h.
  • Batching: Translate up to 5 KB per request to stay under most providers’ payload limits.
  • CDN: Serve static assets (images, JS bundles) via Cloudflare; keep the JSON API behind a CDN edge function for lower latency.

Deployment Checklist

Item Why it matters
HTTPS Required by most translation APIs.
Rate limiting Prevent runaway translation loops.
Monitoring Track translation latency; set alerts if >500 ms.
Environment variables Keep API keys out of source control.

I containerized the whole stack with Docker and orchestrated it on AWS ECS Fargate. Auto‑scaling based on CPU usage kept costs under $30/month during the beta phase.

Real‑World Example

We built HyprNews (https://hyprnews.in) — an AI news app serving 5 Indian languages. The product pulls headlines from over 200 sources, translates them on the fly, and lets users toggle languages instantly. In the first month we observed a 2.3× increase in session duration for users who switched to their native language.

Code Snippet: Translating an Article

import axios from "axios";

async function translate(text, targetLang) {
  const res = await axios.post(
    "https://api.cognitive.microsofttranslator.com/translate",
    [{ Text: text }],
    {
      params: {
        "api-version": "3.0",
        from: "en",
        to: targetLang,
      },
      headers: {
        "Ocp-Apim-Subscription-Key": process.env.AZURE_KEY,
        "Content-Type": "application/json",
      },
    }
  );

  return res.data[0].translations[0].text;
}

Integrate this function into your content service, store the result in Mongo, and you’re good to go.

Conclusion

Building a multilingual news app isn’t a “nice‑to‑have” anymore—users expect content in their own language, especially on mobile. By leveraging AI translation services, a thoughtful caching layer, and a language