This project is an automated system for translating and typesetting books. It uses the Anthropic API for translation and maintains context-awareness for character consistency across different languages. The system is designed to be book-agnostic, allowing for easy adaptation to various literary works.
- Automated translation using the Anthropic API
- Character context management for consistent translations
- EPUB parsing and RMD conversion
- PDF generation using R and LaTeX
- Command-line interface for easy use
book_translator/
│
├── src/
│ ├── translation/
│ │ ├── __init__.py
│ │ ├── translator.py
│ │ ├── character_context.py
│ │ └── api_client.py
│ │
│ ├── formatting/
│ │ ├── __init__.py
│ │ ├── epub_parser.py
│ │ └── rmd_converter.py
│ │
│ ├── typesetting/
│ │ ├── __init__.py
│ │ ├── latex_generator.py
│ │ └── templates/
│ │ ├── book_template.tex
│ │ └── chapter_template.tex
│ │
│ └── utils/
│ ├── __init__.py
│ ├── config.py
│ └── logger.py
│
├── scripts/
│ ├── translate_book.py
│ ├── generate_pdf.R
│ └── manage_characters.py
│
├── tests/
│ ├── test_translation.py
│ ├── test_formatting.py
│ └── test_typesetting.py
│
├── docs/
│ ├── README.md
│ ├── USAGE.md
│ └── API.md
│
├── data/
│ ├── input/
│ └── output/
│
├── ui/ # For future implementation of user interface
│ ├── __init__.py
│ └── main.py
│
├── requirements.txt
├── setup.py
├── .gitignore
├── .env
└── characters.json
-
Clone the repository:
git clone https://github.com/yourusername/book-translator.git cd book-translator -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` -
Install the required dependencies:
pip install -r requirements.txt -
Set up your Anthropic API key: Create a
.envfile in the root directory and add your API key:ANTHROPIC_API_KEY=your_api_key_here -
Prepare your
characters.jsonfile: Create a JSON file with character information. Use the providedmanage_characters.pyscript to add or modify characters.
To add or list characters:
python scripts/manage_characters.py --add --name "Character Name" --gender "Gender" --description "Description" --role "Role" --file "characters.json"
python scripts/manage_characters.py --list --file "characters.json"
To translate a book:
python scripts/translate_book.py --input input.txt --output output.txt --target-language es --characters-file characters.json
(Instructions for using the R script to generate PDF will be added here)
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE.md file for details.
- Anthropic for providing the translation API
- (Add any other acknowledgments here)