DEV Community

myougaTheAxo
myougaTheAxo

Posted on

Publishing Arabic eBooks on KDP Using Claude Code and AI Translation (Full Pipeline)

The Opportunity in Arabic Digital Publishing

The Arabic-speaking world has over 400 million native speakers, yet the Kindle catalog for Arabic content remains surprisingly thin — especially in the self-help and business categories. Western personal finance books, productivity frameworks, and entrepreneurship guides have virtually no Arabic Kindle editions.

This is an arbitrage opportunity. Self-help and business content translates well culturally when adapted properly (Islamic framing, family-oriented context), and Kindle Direct Publishing accepts Arabic EPUB with no additional fees.

My current pipeline produces one publishable Arabic eBook per week using Claude Code as the automation backbone.


The Tech Stack

Layer Tool Why
Translation ChatGPT GPT-4o via local API wrapper Best MSA Arabic quality
EPUB build Python ebooklib + Amiri font RTL support, KDP compatible
Cover Python Pillow 1600x2560 JPG requirement
Automation Claude Code scripts Orchestrates the full pipeline

All tools are either free or covered by a $20/mo ChatGPT Plus subscription.


Translation Pipeline

Why GPT-4o for Arabic

Claude produces acceptable Modern Standard Arabic, but GPT-4o consistently delivers better flow for long-form prose — particularly for formal registers like business writing. For a 10,000-word book, the quality difference is noticeable to native readers.

The key is session persistence. I run GPT-4o through a local API wrapper (localhost:9901) that keeps the session alive across chapters. On first use, I send a setup prompt that stores translation rules in ChatGPT's memory:

def translate_chapter(text: str, session) -> str:
    prompt = f'''Translate to Arabic (MSA). Rules:
- Use formal Modern Standard Arabic
- Replace Western cultural references with Islamic equivalents
- Keep technical terms in English with Arabic explanation in parentheses
- Family framing over individualism

Text:
{text}'''
    return session.send(prompt)
Enter fullscreen mode Exit fullscreen mode

The session persistence means rules only need to be sent once (--setup flag), and subsequent chapters use a lightweight prompt — saving tokens and maintaining consistency.

Cultural Adaptation

Direct translation fails for self-help books. A chapter that says "Be your own boss" needs reframing as "Build something your family will be proud of." References to bank loans get reframed around halal finance concepts. This isn't censorship — it's localization, and it's what separates a $2.99 book from one that earns reviews.

Quality Verification via Back-Translation

After translating each chapter, I run a back-translation check:

def verify_translation(arabic_text: str) -> float:
    back = translate_to_english(arabic_text)
    # Compute semantic similarity score
    return similarity_score(original_english, back)
Enter fullscreen mode Exit fullscreen mode

Chapters scoring below 0.75 similarity get flagged for manual review. In practice, GPT-4o rarely triggers this — but the check catches occasional formatting corruptions where Arabic text got mixed with code blocks.


EPUB Build Essentials

Amiri Font Embedding (Non-Negotiable)

KDP's reader renders Arabic with its own fonts — except when a font is embedded in the EPUB. Without Amiri embedded, Arabic text may render incorrectly on some Kindle devices, especially older ones. Embedding adds ~450KB to the file but is mandatory for correct display.

from ebooklib import epub

def build_epub(chapters: list[dict], output_path: str) -> None:
    book = epub.EpubBook()
    book.set_language("ar")
    book.set_direction("rtl")

    # Embed Amiri font
    with open("fonts/Amiri-Regular.ttf", "rb") as f:
        font_item = epub.EpubItem(
            uid="amiri",
            file_name="fonts/Amiri-Regular.ttf",
            media_type="font/ttf",
            content=f.read(),
        )
    book.add_item(font_item)
Enter fullscreen mode Exit fullscreen mode

RTL CSS Settings

body {
    direction: rtl;
    text-align: right;
    font-family: "Amiri", serif;
    font-size: 1.1em;
    line-height: 1.8;
}

h1, h2, h3 {
    direction: rtl;
    text-align: right;
}

p {
    margin-bottom: 1em;
    text-indent: 1.5em;
}
Enter fullscreen mode Exit fullscreen mode

The direction: rtl on body is not enough — heading elements often need it explicitly, or they revert to LTR in some readers.

Chapter Splitting

A 10,000-word source document gets split into chapters using regex:

import re

def split_chapters(text: str) -> list[str]:
    pattern = r"(?=^#{1,2}\s+.+$)"
    return [c.strip() for c in re.split(pattern, text, flags=re.MULTILINE) if c.strip()]
Enter fullscreen mode Exit fullscreen mode

Each chapter becomes a separate EPUB spine item, which improves navigation on Kindle devices.


KDP Submission

Cover Requirements

KDP requires a JPEG cover with minimum 1600x2560 pixels (2:3.2 ratio). I generate covers with Pillow:

from PIL import Image, ImageDraw, ImageFont

def make_cover(title_ar: str, output_path: str) -> None:
    img = Image.new("RGB", (1600, 2560), color=(18, 18, 18))
    draw = ImageDraw.Draw(img)
    # Draw title in Arabic (RTL layout)
    # ... font loading and text positioning
    img.save(output_path, "JPEG", quality=95)
Enter fullscreen mode Exit fullscreen mode

Right-to-left text placement in Pillow requires manual calculation of text bounding boxes and right-aligning from x=1500.

File and Pricing

  • EPUB file: ~250KB with Amiri embedded, well within KDP's 650MB limit
  • Pricing: $2.99–$4.99 hits the 70% royalty tier (requires $2.99 minimum)
  • Select enrollment: I enroll in KDP Select for 90 days — gives access to Kindle Unlimited readers, which adds ~$0.004/page read on top of sales

Identity Verification

First-time Arabic publishers may hit KDP's identity verification step. This requires uploading a government ID. It's a one-time process and resolves within 3–5 business days. Once cleared, subsequent books publish within 72 hours.


Economics

Item Cost
ChatGPT Plus $20/mo (amortized across multiple projects)
Amiri font Free (SIL Open Font License)
KDP publishing Free
Claude Code Existing subscription
Scenario Revenue
$2.99 at 70% royalty $2.09 per sale
$4.99 at 70% royalty $3.49 per sale
100 sales/month at $2.99 ~$209/mo
100 sales/month at $4.99 ~$349/mo

The actual ceiling is higher — Kindle Unlimited page-read income adds on top of sales, and a back-catalog compounds over time. Month 3 looks different from month 1 because older books keep earning.

A realistic ramp:

  • Month 1: 1 book, 20–40 sales = $40–140
  • Month 3: 4 books, 80–160 combined sales = $160–560
  • Month 6: 10+ books, passive income from back-catalog

Automation with Claude Code

Claude Code orchestrates the pipeline as a series of bash + Python commands. A typical session:

# 1. Feed source document
/translate-arabic source.md --output translated_ar.md

# 2. Build EPUB
python tools/build_epub.py --input translated_ar.md --font fonts/Amiri-Regular.ttf

# 3. Generate cover
python tools/make_cover.py --title "عنوان الكتاب" --output cover.jpg

# 4. Verify EPUB
python tools/verify_epub.py --file output/book_ar.epub
Enter fullscreen mode Exit fullscreen mode

Each script is idempotent — re-running after a failure picks up from where it left off. Claude Code's ability to read error output and adjust the next command is what makes this practical rather than fragile.


What's Next

I'm packaging the full pipeline — translation wrapper, EPUB builder, cover generator, and KDP checklist — as a Claude Code custom skill available on PromptWorks.

The skill handles the entire workflow from raw Markdown source to a KDP-ready ZIP with EPUB + cover. One command, one output, ready to upload.

👉 Check the Arabic eBook Pipeline Skill at PromptWorks — and browse other Claude Code automation skills at note.com/myougatheaxo

Top comments (0)