# Simple script to translate a Markdown file python - <<'PY' from deep_translator import DeepLTranslator import pathlib, sys, re
pdftotext output/system_xyz_ar.pdf - | grep -q "[\x0600-\x06FF]" && echo "✅ Arabic text detected" | Channel | Recommended format | |---------|--------------------| | Email / intranet | PDF (max 10 MB, compressed). | | Web download | PDF + an HTML version (run pandoc -t html5 ). | | Printed manual | Use the same PDF; print with a printer that supports RTL (most modern printers do). |
# Restore code blocks for key, block in placeholders.items(): translated = translated.replace(key, block)
% RTL support \usepackagebidi \setlength\parindent0pt \setlength\parskip6pt ktab my system mtrjm llrbyt pdf
Write a tiny Bash script that runs pdftotext (poppler) on the PDF and greps for Arabic characters to ensure they are present and not image‑only.
Optional: Add a ( openssl ) if the document must be tamper‑proof.
dst.write_text(translated, encoding='utf-8') print('✅ Translation saved to', dst) PY Run the script on sections (e.g., one chapter at a time) to avoid hitting API limits and to make post‑editing easier. 2.4.2 Post‑Editing Checklist | Item | What to look for | |------|------------------| | Technical terminology | Verify against your glossary. | | Numbers & units | Keep Arabic numerals ( ١٢٣ ) or Western ( 123 ) consistently (choose one). | | Directionality | Ensure bullet lists, tables, and headings flow RTL. | | Code snippets | Keep them as‑is (English) – wrap them in a left‑to‑right block. | | Figures & screenshots | Add Arabic captions ( \caption... ) and, if needed, mirror UI screenshots. | 2.5 Polish the Arabic Document 2.5.1 Create a Pandoc Template (Arabic‑Ready) Save this as templates/arabic.tex : # Simple script to translate a Markdown file
\documentclass[12pt]article \usepackagefontspec \usepackagepolyglossia \setmainlanguagearabic \setotherlanguageenglish \newfontfamily\arabicfont[Script=Arabic]Noto Sans Arabic \newfontfamily\englishfontLatin Modern Roman
$body$
# macOS (Homebrew) brew install pandoc brew install --cask mactex-no-gui # includes XeLaTeX | # Restore code blocks for key, block in placeholders
% Code blocks (left‑to‑right) \usepackagelistings \lstset basicstyle=\ttfamily\small, language=, breaklines=true, frame=single, numbers=left, numberstyle=\tiny, xleftmargin=0.5cm, xrightmargin=0.5cm, columns=fullflexible, keepspaces=true, escapeinside=(*@@*)
| Font | Why | |------|-----| | (Google) | Clean, open‑source, covers all Unicode Arabic ranges. | | Amiri | Classic book‑style, great for printed manuals. | | Scheherazade | Good for body text with nice ligatures. | 2.4 Translate the Content 2.4.1 Using a CLI MT Engine (DeepL Example) # Install deep-translator Python package pip install deep-translator
| Flag | Meaning | |------|---------| | --from markdown+yaml_metadata_block | Accepts front‑matter for title, author, date, etc. | | --template=... | Our custom RTL LaTeX template. | | --pdf-engine=xelatex | XeLaTeX understands Unicode & modern fonts. | | --toc | Auto‑generates a table of contents (Arabic page numbers). | | --metadata title="..." | Sets the Arabic title that appears on the cover page. | | QC Item | How to verify | |---------|----------------| | Spelling & grammar | Use LanguageTool (Arabic mode) or Microsoft Editor . | | RTL rendering | Open PDF in Acrobat Reader → check that paragraphs start on the right and that bullet points point left. | | Clickable TOC | Verify that each entry jumps to the right page. | | Figures | Captions are Arabic, numbers are right‑aligned. | | Code blocks | Still left‑to‑right, monospaced, no broken characters. | | Accessibility | Run pdfinfo or Acrobat’s “Read Out Loud” to ensure Arabic text is selectable (not rasterized). |
\endRTL \enddocument pandoc \ --from markdown+yaml_metadata_block \ --template=templates/arabic.tex \ --pdf-engine=xelatex \ --toc \ --metadata title="دليل نظام XYZ" \ --output output/system_xyz_ar.pdf \ draft/system_ar.md Explanation of flags