Skip to content

Translation

John R. D'Orazio edited this page Feb 27, 2026 · 1 revision

Translation

How to produce translated versions of the bylaws in any language.


Prerequisites

  • Node.js with npm install completed in the repo root
  • Pandoc installed as a system dependency (installation docs)
  • An OpenAI API key with access to the gpt-4o model

Setup

Set the OPENAI_API_KEY environment variable. You can either export it directly:

export OPENAI_API_KEY="sk-..."

Or create a .env.local file in the repo root (git-ignored):

OPENAI_API_KEY=sk-...

The translation script loads .env.local automatically if present.


Usage

Translate to one or more languages using BCP 47 language codes:

# Single language
npm run translate -- --lang es

# Multiple languages
npm run translate -- --lang es --lang fr --lang la

What the script does

For each requested language, scripts/translate.js performs three steps:

  1. Translate — Sends BYLAWS.md to the OpenAI API (gpt-4o, temperature 0.2) with a legal translation prompt. The prompt preserves:

    • All Markdown formatting
    • The metadata block (Version:, Original Adoption Date:, Last Amended:) verbatim
    • The organization name "Catholic Digital Commons Foundation" verbatim
    • Legal citations (e.g. "Section 501(c)(3)") verbatim
    • Ecclesiastical terms are translated naturally (e.g. "Holy See" becomes "Santa Sede" in Spanish)
  2. Convert to HTML — Runs Pandoc to produce a standalone HTML file with the print stylesheet embedded.

  3. Generate PDF — Runs pagedjs-cli to produce a print-ready PDF.


Output files

For each language code (e.g. es):

File Description
dist/bylaws-es.md Translated Markdown
dist/bylaws-es-standalone.html Self-contained HTML with embedded CSS
dist/bylaws-es.pdf Print-ready PDF (US Letter)

Examples

# Spanish
npm run translate -- --lang es

# Latin and Italian
npm run translate -- --lang la --lang it

# French
npm run translate -- --lang fr

Notes

  • Translations are generated on demand and are not committed to the repository. The dist/ directory is git-ignored.
  • The translation uses the same print stylesheet (scripts/bylaws-print.css) and fonts as the English PDF.
  • For official translated documents, review the output for legal accuracy before distribution.

Clone this wiki locally