Systems Library / Operations & Admin / How to Build an AI Translation System for Team Communication
Operations & Admin communication

How to Build an AI Translation System for Team Communication

Translate team messages in real-time for multilingual organizations.

Jay Banlasan

Jay Banlasan

The AI Systems Guy

Multilingual teams waste time repeating things in different languages. I built an ai translation system for team communication that translates Slack messages, documents, and announcements in real time. Everyone reads in their preferred language without anyone manually translating.

One message goes out. Each person sees it in their language.

What You Need Before Starting

Step 1: Define Language Preferences

TEAM_LANGUAGES = {
    "alice": {"preferred": "en", "can_read": ["en", "es"]},
    "bob": {"preferred": "es", "can_read": ["es", "en"]},
    "carol": {"preferred": "fr", "can_read": ["fr", "en"]},
    "dave": {"preferred": "ja", "can_read": ["ja", "en"]},
}

SUPPORTED_LANGUAGES = {
    "en": "English", "es": "Spanish", "fr": "French",
    "de": "German", "ja": "Japanese", "pt": "Portuguese",
    "zh": "Chinese", "ko": "Korean"
}

Step 2: Build the Translation Engine

import anthropic

client = anthropic.Anthropic()

def translate_message(text, source_lang, target_lang):
    if source_lang == target_lang:
        return text

    prompt = f"""Translate this text from {SUPPORTED_LANGUAGES[source_lang]} to {SUPPORTED_LANGUAGES[target_lang]}.
Preserve tone, technical terms, and formatting.
Return only the translation, nothing else.

Text: {text}"""

    message = client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=1024,
        messages=[{"role": "user", "content": prompt}]
    )
    return message.content[0].text

def detect_language(text):
    prompt = f"""What language is this text written in? Return only the ISO 639-1 code (en, es, fr, de, ja, etc).

Text: {text[:200]}"""

    message = client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=10,
        messages=[{"role": "user", "content": prompt}]
    )
    return message.content[0].text.strip().lower()

Step 3: Integrate with Slack

from slack_bolt import App
import requests

app = App(token="xoxb-your-bot-token")

@app.event("message")
def handle_message(event, client):
    text = event.get("text", "")
    channel = event["channel"]
    user = event.get("user", "")

    if event.get("subtype") == "bot_message":
        return

    source_lang = detect_language(text)

    languages_needed = set()
    for member, prefs in TEAM_LANGUAGES.items():
        if prefs["preferred"] != source_lang and source_lang not in prefs["can_read"]:
            languages_needed.add(prefs["preferred"])

    if not languages_needed:
        return

    translations = {}
    for lang in languages_needed:
        translations[lang] = translate_message(text, source_lang, lang)

    translation_text = "\n".join(
        f"*{SUPPORTED_LANGUAGES[lang]}:* {trans}" for lang, trans in translations.items()
    )

    client.chat_postMessage(
        channel=channel,
        thread_ts=event["ts"],
        text=f"Translations:\n{translation_text}"
    )

Step 4: Translate Documents

def translate_document(filepath, target_lang):
    from pathlib import Path
    content = Path(filepath).read_text(encoding="utf-8")
    source_lang = detect_language(content[:500])

    chunks = [content[i:i+2000] for i in range(0, len(content), 2000)]
    translated_chunks = []

    for chunk in chunks:
        translated = translate_message(chunk, source_lang, target_lang)
        translated_chunks.append(translated)

    translated_content = "".join(translated_chunks)

    output_path = filepath.replace(".md", f"_{target_lang}.md")
    Path(output_path).write_text(translated_content, encoding="utf-8")
    return output_path

Step 5: Cache Translations

import sqlite3
import hashlib

def init_translation_cache(db_path="translations.db"):
    conn = sqlite3.connect(db_path)
    conn.execute("""
        CREATE TABLE IF NOT EXISTS cache (
            text_hash TEXT,
            source_lang TEXT,
            target_lang TEXT,
            translation TEXT,
            created_at TEXT,
            PRIMARY KEY (text_hash, source_lang, target_lang)
        )
    """)
    conn.commit()
    return conn

def cached_translate(conn, text, source_lang, target_lang):
    text_hash = hashlib.md5(text.encode()).hexdigest()

    cached = conn.execute(
        "SELECT translation FROM cache WHERE text_hash=? AND source_lang=? AND target_lang=?",
        (text_hash, source_lang, target_lang)
    ).fetchone()

    if cached:
        return cached[0]

    translation = translate_message(text, source_lang, target_lang)
    conn.execute(
        "INSERT OR REPLACE INTO cache VALUES (?,?,?,?,?)",
        (text_hash, source_lang, target_lang, translation, __import__('datetime').datetime.now().isoformat())
    )
    conn.commit()
    return translation

What to Build Next

Add meeting translation that transcribes a call and generates notes in each participant's language simultaneously. The translation cache reduces API costs over time as common phrases get reused.

Related Reading

Want this system built for your business?

Get a free assessment. We will map every system your business needs and show you the ROI.

Get Your Free Assessment

Related Systems