Skip to content

Repository files navigation

GitHub Stars GitHub Forks Watchers Contributors License


Python Docker Ollama

Extractor and Translation

Text extraction and translation tool for RPG Maker games and JSON i18n files.

Read this in other languages: Português

📖 About

Extractor and Translation is a Python-based tool designed to extract translatable text from specific formats and automate its translation using AI models via Ollama. It leverages modern libraries like PyQt5 for a GUI and deep_translator/Ollama for translating game assets and localization JSON files efficiently. It simplifies the localization process by managing the context and concurrency of requests to the AI engine.

📋 Reason

The project was initially created to translate RPG Maker games, and later the concept evolved to also translate website JSON i18n files.

💻 Getting Started

Requirements

Installation

  1. Clone the repository:
git clone https://github.com/bgluis/extractor-and-translation.git
  1. Navigate to the project directory:
cd extractor-and-translation

Method 1: Native Execution (Python)

  1. Create and activate a virtual environment (optional but recommended):
python -m venv .venv
source .venv/bin/activate  # On Windows use: .venv\Scripts\activate
  1. Install the dependencies:
pip install -r requirements.txt
  1. Run the application:
python main.py

Method 2: Global CLI Installation with Shortcuts (Slime)

You can install the executable globally with pre-configured terminal shortcuts/abbreviations (slime, slm, sl):

# Installs 'slime' and shortcuts (slm, sl, extractor-translation) into ~/.local/bin
make install-cli

After installation, you can run the tool from any folder:

# Start interactive mode:
slime
# or with shortcuts:
slm
sl --interactive

# Direct translation:
slm -i /path/to/game -e RPGMaker -t Google -s ja -d pt

# Launch GUI:
slime --gui

# Add custom aliases/abbreviations:
make add-alias ALIAS=slx
# or directly:
slime --add-alias slx
  1. Build and start the container using Docker Compose:
docker-compose up -d --build

⚙️ Environment Variables

The application uses environment variables for configuration. You can copy .env.example to .env and adjust the values.

Variable Description Default Value
OLLAMA_MODEL Ollama model to be used for translation (e.g., llama3.1, mistral) llama3.1
OLLAMA_MAX_REQUESTS Maximum number of concurrent requests to the model 5
OLLAMA_CHAR_LIMIT Character limit per request (optional) 10000
OLLAMA_CONTEXT_FUNCTION Custom function context for the prompt (optional) -
OLLAMA_CONTEXT_ADDITIONAL Additional context for the prompt (optional) -

🤝 Contributors

About

Python GUI tool (PyQt5) to extract and translate RPG Maker games and JSON i18n files using local AI models via Ollama.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages