len: Minstral additions (also add start.sh)

This commit is contained in:
DazedAnon 2026-06-13 14:32:57 -05:00
parent 232df0bc7a
commit 80d203ec06
6 changed files with 4752 additions and 4193 deletions

View file

@ -1,3 +1,17 @@
# --------------------------------------------------
# Mistral-Specific Settings (Optional)
# --------------------------------------------------
# Budgets for the adaptive rate limiter. Mistral enforces a per-MINUTE request
# limit and a per-minute token limit, both PER-MODEL (e.g. mistral-medium is
# 25 req/min, ministral-3b is 750/min). The tool reads these from the live
# ratelimit response headers and paces calls so you never trip a 429 — so
# these seeds only matter for the very first request of a run.
# mistralReqPerSec is the per-SECOND seed (req-per-minute / 60).
#mistralReqPerSec="0.5"
#mistralTokPerMin="50000"
#mistralTokenHeadroom="4000"
# -------------------------------------------------- # --------------------------------------------------
# Gemini-Specific Settings (Optional) # Gemini-Specific Settings (Optional)
# -------------------------------------------------- # --------------------------------------------------
@ -9,11 +23,13 @@
# - Leave this variable out to use the model's default setting. # - Leave this variable out to use the model's default setting.
GEMINI_THINKING_BUDGET= GEMINI_THINKING_BUDGET=
# Set to "gemini" to use the Gemini API or "openai" for OpenAI-compatible APIs (If empty it will default to openai.) # Set to "gemini" to use the Gemini API, "mistral" for Mistral (la Plateforme),
# or "openai" for OpenAI-compatible APIs (If empty it will default to openai.)
API_PROVIDER=openai API_PROVIDER=openai
# API URL, leave blank to use OpenAI API. # API URL, leave blank to use OpenAI API.
# Nvidia example: "https://integrate.api.nvidia.com/v1/" # Nvidia example: "https://integrate.api.nvidia.com/v1/"
# Mistral example: "https://api.mistral.ai/v1/"
api="" api=""
# API key # API key
@ -24,6 +40,8 @@ organization=""
# LLM model name. # LLM model name.
# Default below works for OpenAI; for Gemini/Nvidia set your provider model name. # Default below works for OpenAI; for Gemini/Nvidia set your provider model name.
# For Mistral, "mistral-medium-3.5" is the recommended model
# (avoid "mistral-medium-latest" — it still points at the older 3.1).
model="gpt-4.1" model="gpt-4.1"
#The language to translate TO, Don't forget to change the prompt #The language to translate TO, Don't forget to change the prompt

826
README.md
View file

@ -1,408 +1,420 @@
# DazedMTLTool # DazedMTLTool
An AI-powered game translation tool with a GUI. Translate RPG Maker, Ren'Py, Tyrano, Wolf RPG, Kirikiri, and other game engines from Japanese to English using GPT or compatible AI models. An AI-powered game translation tool with a GUI. Translate RPG Maker, Ren'Py, Tyrano, Wolf RPG, Kirikiri, and other game engines from Japanese to English using GPT or compatible AI models.
## Credits ## Credits
- **[Sinflower](https://github.com/Sinflower)** — [RV2JSON](https://github.com/Sinflower/RV2JSON) — enables RPGMaker Ace games to be translated the same way as MV/MZ by converting rvdata2 files to JSON and back. A copy is bundled offline in `util/ace/offline/`; newer builds are downloaded when online. - **[Sinflower](https://github.com/Sinflower)** — [RV2JSON](https://github.com/Sinflower/RV2JSON) — enables RPGMaker Ace games to be translated the same way as MV/MZ by converting rvdata2 files to JSON and back. A copy is bundled offline in `util/ace/offline/`; newer builds are downloaded when online.
- **Sakura & Kao_SSS** — TL Inspector (`util/tl_inspector/`) — in-game translation source inspector and live-edit plugin for RPG Maker MV/MZ playtesting. - **Sakura & Kao_SSS** — TL Inspector (`util/tl_inspector/`) — in-game translation source inspector and live-edit plugin for RPG Maker MV/MZ playtesting.
- **Len** — batch translation mode — Anthropic Message Batches API integration (collect/consume pipeline, cost estimation, resume, and GUI/workflow support). - **Len** — batch translation mode — Anthropic Message Batches API integration (collect/consume pipeline, cost estimation, resume, and GUI/workflow support).
## Table of Contents ## Table of Contents
- [Supported Engines](#supported-engines) - [Supported Engines](#supported-engines)
- [Requirements](#requirements) - [Requirements](#requirements)
- [Installing Python](#installing-python) - [Installing Python](#installing-python)
- [Quick Start](#quick-start) - [Quick Start](#quick-start)
- [Using the GUI](#using-the-gui) - [Using the GUI](#using-the-gui)
- [Vocab & Prompt](#vocab--prompt) - [Vocab & Prompt](#vocab--prompt)
- [Tips](#tips) - [Tips](#tips)
- [Batch Translation (Anthropic, 50% off)](#batch-translation-anthropic-50-off) - [Batch Translation (Anthropic, 50% off)](#batch-translation-anthropic-50-off)
- [Folder Structure](#folder-structure) - [Folder Structure](#folder-structure)
- [Finding Untranslated Text (Snipping Tool OCR)](#finding-untranslated-text-snipping-tool-ocr) - [Finding Untranslated Text (Snipping Tool OCR)](#finding-untranslated-text-snipping-tool-ocr)
- [RPG Maker Translation Workflow](#rpg-maker-translation-workflow) - [RPG Maker Translation Workflow](#rpg-maker-translation-workflow)
- [Using Copilot & VSCode](#using-copilot--vscode) - [Using Copilot & VSCode](#using-copilot--vscode)
- [Version Control with Git](#version-control-with-git) - [Version Control with Git](#version-control-with-git)
- [Troubleshooting](#troubleshooting) - [Troubleshooting](#troubleshooting)
## Supported Engines ## Supported Engines
- RPG Maker (MV, MZ, Ace, and more) - RPG Maker (MV, MZ, Ace, and more)
- Wolf RPG Editor - Wolf RPG Editor
- Ren'Py - Ren'Py
- TyranoBuilder / TyranoScript - TyranoBuilder / TyranoScript
- Kirikiri - Kirikiri
- NScripter - NScripter
- CSV / Text files - CSV / Text files
--- ---
## Requirements ## Requirements
- **Python 3.12 3.14** — See [Installing Python](#installing-python) below if you don't have it yet. - **Python 3.12 3.14** — See [Installing Python](#installing-python) below if you don't have it yet.
- **An AI API Key** — You'll need an API key from [OpenAI](https://platform.openai.com/settings/organization/api-keys), [Google Gemini](https://aistudio.google.com/apikey), or a compatible provider. - **An AI API Key** — You'll need an API key from [OpenAI](https://platform.openai.com/settings/organization/api-keys), [Google Gemini](https://aistudio.google.com/apikey), or a compatible provider.
--- ---
## Installing Python ## Installing Python
If you already have Python 3.123.14 installed and working, skip to [Quick Start](#quick-start). If you already have Python 3.123.14 installed and working, skip to [Quick Start](#quick-start).
### Step 1 — Download ### Step 1 — Download
Go to [python.org/downloads](https://www.python.org/downloads/) and download **Python 3.13** (or any version from 3.12 to 3.14). Go to [python.org/downloads](https://www.python.org/downloads/) and download **Python 3.13** (or any version from 3.12 to 3.14).
### Step 2 — Install (Important!) ### Step 2 — Install (Important!)
When the installer opens, **check both boxes at the bottom before clicking Install**: When the installer opens, **check both boxes at the bottom before clicking Install**:
- ✅ **"Add python.exe to PATH"** — This is the most important step. Without it, your system won't be able to find Python. - ✅ **"Add python.exe to PATH"** — This is the most important step. Without it, your system won't be able to find Python.
- ✅ **"Use admin privileges when installing pip"** - ✅ **"Use admin privileges when installing pip"**
Then click **Install Now**. The default settings are fine for everything else. Then click **Install Now**. The default settings are fine for everything else.
### Step 3 — Verify ### Step 3 — Verify
Open a **new** terminal window (don't reuse an old one — it won't see the new PATH) and run: Open a **new** terminal window (don't reuse an old one — it won't see the new PATH) and run:
``` ```
python -V python -V
``` ```
You should see something like `Python 3.13.x`. Then check pip: You should see something like `Python 3.13.x`. Then check pip:
``` ```
pip -V pip -V
``` ```
You should see something like `pip 24.x.x from ...`. You should see something like `pip 24.x.x from ...`.
### If `python` or `pip` is not recognized ### If `python` or `pip` is not recognized
This means Python wasn't added to your PATH. You have two options: This means Python wasn't added to your PATH. You have two options:
**Option A — Reinstall (easiest)** **Option A — Reinstall (easiest)**
1. Open the Python installer again (or redownload it). 1. Open the Python installer again (or redownload it).
2. Select **Modify**. 2. Select **Modify**.
3. Click **Next** on the first screen. 3. Click **Next** on the first screen.
4. On the Advanced Options screen, check **"Add Python to environment variables"**. 4. On the Advanced Options screen, check **"Add Python to environment variables"**.
5. Click **Install**. Then open a **new** terminal and try again. 5. Click **Install**. Then open a **new** terminal and try again.
**Option B — Add to PATH manually** **Option B — Add to PATH manually**
1. Press `Win+R`, type `sysdm.cpl`, press Enter. 1. Press `Win+R`, type `sysdm.cpl`, press Enter.
2. Go to the **Advanced** tab → **Environment Variables**. 2. Go to the **Advanced** tab → **Environment Variables**.
3. Under **System variables**, find `Path` and click **Edit**. 3. Under **System variables**, find `Path` and click **Edit**.
4. Click **New** and add the path where Python was installed. Typically: 4. Click **New** and add the path where Python was installed. Typically:
- `C:\Users\YourName\AppData\Local\Programs\Python\Python313\` - `C:\Users\YourName\AppData\Local\Programs\Python\Python313\`
- `C:\Users\YourName\AppData\Local\Programs\Python\Python313\Scripts\` - `C:\Users\YourName\AppData\Local\Programs\Python\Python313\Scripts\`
5. Click **OK** on all dialogs, then open a **new** terminal and try `python -V` again. 5. Click **OK** on all dialogs, then open a **new** terminal and try `python -V` again.
> **Tip:** If `python` works but `pip` doesn't, try `python -m pip -V` instead. If that works, you can use `python -m pip install` anywhere you'd normally use `pip install`. > **Tip:** If `python` works but `pip` doesn't, try `python -m pip -V` instead. If that works, you can use `python -m pip install` anywhere you'd normally use `pip install`.
--- ---
## Quick Start ## Quick Start
### 1. Download the Tool ### 1. Download the Tool
1. Click the green **Code** button at the top of this page and select **Download ZIP**. 1. Click the green **Code** button at the top of this page and select **Download ZIP**.
2. Extract the ZIP to a folder of your choice (e.g., `C:\DazedMTLTool`). 2. Extract the ZIP to a folder of your choice (e.g., `C:\DazedMTLTool`).
### 2. Set Up Your API Key ### 2. Set Up Your API Key
1. Inside the tool folder, find `.env.example` and make a copy of it named `.env`. 1. Inside the tool folder, find `.env.example` and make a copy of it named `.env`.
2. Open `.env` in any text editor (Notepad works fine) and fill in your API details: 2. Open `.env` in any text editor (Notepad works fine) and fill in your API details:
- `api` — Your API base URL (for Nvidia use `https://integrate.api.nvidia.com/v1/`). - `api` — Your API base URL (for Nvidia use `https://integrate.api.nvidia.com/v1/`, for Mistral use `https://api.mistral.ai/v1/`).
- `key` — Your API key. - `key` — Your API key.
- `organization` — Your organization key (make something up if using a self-hosted or non-OpenAI API). - `organization` — Your organization key (make something up if using a self-hosted or non-OpenAI API).
- `API_PROVIDER` — Use `openai` for OpenAI-compatible providers (including Nvidia), or `gemini` for Gemini. - `API_PROVIDER` — Use `openai` for OpenAI-compatible providers (including Nvidia), `gemini` for Gemini, or `mistral` for Mistral (only needed when `api` is left empty).
- `model` — For Nvidia/custom OpenAI-compatible endpoints, enter the model name manually (example: `deepseek-ai/deepseek-v4-pro`). - `model` — For Nvidia/custom OpenAI-compatible endpoints, enter the model name manually (example: `deepseek-ai/deepseek-v4-pro`).
3. The rest of the settings (wordwrap, batch size, etc.) can be left as defaults for now. You can tweak them later. 3. The rest of the settings (wordwrap, batch size, etc.) can be left as defaults for now. You can tweak them later.
### 3. Launch the GUI > **Mistral note:** When the API URL points at `api.mistral.ai`, requests are paced by an
> adaptive rate limiter. Mistral enforces a **per-minute request limit** and a **per-minute
**Double-click `START.bat`**. It will: > token limit**, both of which are **per-model** — e.g. `mistral-medium` allows 25 req/min
- Create a virtual environment automatically. > while `ministral-3b` allows 750/min (Mistral's dashboard shows these ÷60 as "RPS", so the
- Install all dependencies. > effective rate ranges from well under 1 to over 12 requests/sec depending on the model). The
- Launch the GUI. > limiter reads both limits straight from the live `x-ratelimit-*` response headers, spaces
> requests so it never overruns the per-minute request budget, charges them against a rolling
That's it! From now on, just double-click `START.bat` to open the tool. > per-minute token budget, and honours `Retry-After` on 429s. It starts from a conservative
> seed and pins itself to the exact per-model rate after the first response — so you can run
--- > multiple `fileThreads` and it won't error out, it just paces the calls. Override the seeds
> with `mistralReqPerSec`, `mistralTokPerMin`, and `mistralTokenHeadroom` if needed (rarely).
## Using the GUI
### 3. Launch the GUI
The GUI has several tabs that handle different parts of the translation process:
**Double-click `START.bat`**. It will:
### Config Tab - Create a virtual environment automatically.
This is where you configure your API settings, wordwrap widths, and other options. Most of these mirror what's in the `.env` file, but you can adjust them visually. - Install all dependencies.
- Launch the GUI.
### Translation Tab
The main tab for translating files. That's it! From now on, just double-click `START.bat` to open the tool.
1. **Add files** — Place the game files you want to translate into the `files` folder (inside the tool directory). ---
2. **Select a module** — Pick the engine that matches your game (e.g., RPG Maker MV/MZ, Wolf RPG, Ren'Py, etc.).
3. **Click Translate** — The tool will process each file and output translated versions to the `translated` folder. ## Using the GUI
4. **Copy the results** — Move the translated files from `translated` back into your game's data folder.
The GUI has several tabs that handle different parts of the translation process:
### Engine Config Tab
Engine-specific settings. RPG Maker has the most mature support — you can toggle exactly which event codes to translate (dialogue, choices, variables, plugin commands, etc.). The defaults cover ~95% of a game's text out of the box. See the [RPG Maker Translation Workflow](#rpg-maker-translation-workflow) section for a detailed step-by-step guide. ### Config Tab
This is where you configure your API settings, wordwrap widths, and other options. Most of these mirror what's in the `.env` file, but you can adjust them visually.
Other engines (Wolf RPG, Ren'Py, Tyrano, etc.) have less granular support and may require more manual tweaking or post-editing depending on the game.
### Translation Tab
### RPG Maker / Wolf / CSV Tabs The main tab for translating files.
Specialized tabs with extra options for those specific engines.
1. **Add files** — Place the game files you want to translate into the `files` folder (inside the tool directory).
--- 2. **Select a module** — Pick the engine that matches your game (e.g., RPG Maker MV/MZ, Wolf RPG, Ren'Py, etc.).
3. **Click Translate** — The tool will process each file and output translated versions to the `translated` folder.
## Vocab & Prompt 4. **Copy the results** — Move the translated files from `translated` back into your game's data folder.
### vocab.txt ### Engine Config Tab
This file gives the AI context about your game — character names, genders, recurring terms, etc. The better your vocab file, the more consistent the translation. Engine-specific settings. RPG Maker has the most mature support — you can toggle exactly which event codes to translate (dialogue, choices, variables, plugin commands, etc.). The defaults cover ~95% of a game's text out of the box. See the [RPG Maker Translation Workflow](#rpg-maker-translation-workflow) section for a detailed step-by-step guide.
Open `vocab.txt` (or copy `vocab.txt.example` to `vocab.txt` if it doesn't exist) and add entries like: Other engines (Wolf RPG, Ren'Py, Tyrano, etc.) have less granular support and may require more manual tweaking or post-editing depending on the game.
```plaintext ### RPG Maker / Wolf / CSV Tabs
# Game Characters Specialized tabs with extra options for those specific engines.
水無月 士乃 (Minazuki Shino) - Female
暗黒斎 (Dark Kokusai) - Male ---
フトシ (Futoshi) - Male
``` ## Vocab & Prompt
Format: Japanese name, English name in parentheses, then gender. ### vocab.txt
This file gives the AI context about your game — character names, genders, recurring terms, etc. The better your vocab file, the more consistent the translation.
> **Note:** A very large vocab file can increase API costs and potentially reduce quality. Focus on the most important characters and terms.
Open `vocab.txt` (or copy `vocab.txt.example` to `vocab.txt` if it doesn't exist) and add entries like:
### prompt.txt
This is the system prompt sent to the AI. A default `prompt.txt` is included and works well for most games. You generally don't need to edit it unless you want to customize the translation style. ```plaintext
# Game Characters
--- 水無月 士乃 (Minazuki Shino) - Female
暗黒斎 (Dark Kokusai) - Male
## Tips フトシ (Futoshi) - Male
```
- **Check `log/translations.txt`** after a run to see what was translated. You can copy useful terms from it into `vocab.txt` for consistency in future runs.
- **Start small** — Translate a few files first to make sure the output looks good before doing the whole game. Format: Japanese name, English name in parentheses, then gender.
- **Wordwrap** — If text overflows or looks awkward in-game, adjust the `width` setting in `.env` or the Config tab. `60` is a good default for most RPG Maker games.
- **Version control** — Using [Git](https://git-scm.com/) with the game folder is highly recommended. It lets you track every change the translation makes, compare with original files, and roll back if needed. > **Note:** A very large vocab file can increase API costs and potentially reduce quality. Focus on the most important characters and terms.
--- ### prompt.txt
This is the system prompt sent to the AI. A default `prompt.txt` is included and works well for most games. You generally don't need to edit it unless you want to customize the translation style.
## Batch Translation (Anthropic, 50% off)
---
Batch mode was contributed by **Len** — see [Credits](#credits).
## Tips
When using a Claude model, the CLI offers a third mode that translates through the
[Anthropic Message Batches API](https://platform.claude.com/docs/en/build-with-claude/batch-processing.md) - **Check `log/translations.txt`** after a run to see what was translated. You can copy useful terms from it into `vocab.txt` for consistency in future runs.
— every token (input, output, and prompt-cache reads/writes) is billed at **50% of the live price**. - **Start small** — Translate a few files first to make sure the output looks good before doing the whole game.
Batches usually finish within an hour (24h worst case), so use it for large jobs where you don't - **Wordwrap** — If text overflows or looks awkward in-game, adjust the `width` setting in `.env` or the Config tab. `60` is a good default for most RPG Maker games.
need results immediately. - **Version control** — Using [Git](https://git-scm.com/) with the game folder is highly recommended. It lets you track every change the translation makes, compare with original files, and roll back if needed.
``` ---
python start.py
-> 3. Batch Translate (Anthropic Batches API, 50% off) ## Batch Translation (Anthropic, 50% off)
```
Batch mode was contributed by **Len** — see [Credits](#credits).
How it works (all engine modules are supported automatically):
When using a Claude model, the CLI offers a third mode that translates through the
1. **Pass 1 (collect)** — files are processed normally, but instead of calling the API each [Anthropic Message Batches API](https://platform.claude.com/docs/en/build-with-claude/batch-processing.md)
request is queued to `log/batch_requests.json`. Requests are byte-identical to live ones: — every token (input, output, and prompt-cache reads/writes) is billed at **50% of the live price**.
the static `prompt.txt` block is cached with a 1h TTL, matched vocab and translation Batches usually finish within an hour (24h worst case), so use it for large jobs where you don't
history ride along per request, and structured output enforces the exact line count. need results immediately.
Speaker/variable names still translate live during this pass (they get embedded into the
dialogue payloads, so both passes must resolve them identically) — they're a tiny share ```
of the volume. python start.py
2. **Cost estimate** — before anything is submitted you get a cost breakdown -> 3. Batch Translate (Anthropic Batches API, 50% off)
(batch + cache / batch worst-case / live price) and a y/n confirmation. ```
3. **Submit / poll / fetch** — the batch is submitted, polled until it ends
(`batchPollInterval` env var controls the interval, default 60s), and the results are How it works (all engine modules are supported automatically):
saved to `log/batch_results.json`. Ctrl-C while polling is safe — the batch keeps
processing server-side. 1. **Pass 1 (collect)** — files are processed normally, but instead of calling the API each
4. **Pass 2 (consume)** — files are processed again; every payload is filled from the batch request is queued to `log/batch_requests.json`. Requests are byte-identical to live ones:
results through the normal validation pipeline (line counts, placeholders, content the static `prompt.txt` block is cached with a 1h TTL, matched vocab and translation
checks). Anything the batch missed or that fails validation falls back to the live API history ride along per request, and structured output enforces the exact line count.
automatically, so the output is always complete. Speaker/variable names still translate live during this pass (they get embedded into the
dialogue payloads, so both passes must resolve them identically) — they're a tiny share
Context note: in live mode the rolling translation history contains the previous batch's of the volume.
English lines; in batch mode requests are independent, so the history carries the previous 2. **Cost estimate** — before anything is submitted you get a cost breakdown
batch's *source* lines instead. The model still sees the surrounding scene, and `vocab.txt` (batch + cache / batch worst-case / live price) and a y/n confirmation.
keeps names and terms consistent — so keep your vocab file in good shape for batch runs. 3. **Submit / poll / fetch** — the batch is submitted, polled until it ends
(`batchPollInterval` env var controls the interval, default 60s), and the results are
Cost tracking is exact: per-file and total costs printed after the consume pass use the real saved to `log/batch_results.json`. Ctrl-C while polling is safe — the batch keeps
billed token counts (cache reads at 0.1x, cache writes at 2x, output at the output rate) with processing server-side.
the 50% batch discount applied. 4. **Pass 2 (consume)** — files are processed again; every payload is filled from the batch
results through the normal validation pipeline (line counts, placeholders, content
`python selftest_batch.py` round-trips the whole flow offline (no API key needed) if you want checks). Anything the batch missed or that fails validation falls back to the live API
to verify the pipeline after making changes. automatically, so the output is always complete.
--- Context note: in live mode the rolling translation history contains the previous batch's
English lines; in batch mode requests are independent, so the history carries the previous
## Folder Structure batch's *source* lines instead. The model still sees the surrounding scene, and `vocab.txt`
keeps names and terms consistent — so keep your vocab file in good shape for batch runs.
| Folder | Purpose |
|---|---| Cost tracking is exact: per-file and total costs printed after the consume pass use the real
| `files/` | Place game files here before translating | billed token counts (cache reads at 0.1x, cache writes at 2x, output at the output rate) with
| `translated/` | Translated output appears here | the 50% batch discount applied.
| `log/` | Translation logs and cache |
| `modules/` | Engine-specific translation scripts | `python selftest_batch.py` round-trips the whole flow offline (no API key needed) if you want
| `gui/` | GUI source code | to verify the pipeline after making changes.
--- ---
## Finding Untranslated Text (Snipping Tool OCR) ## Folder Structure
When playtesting a translated game, you'll inevitably find text that was missed or needs fixing. The fastest way to grab Japanese text from the screen and search for it in the game files is with the **Windows 11 Snipping Tool** — its built-in OCR is far better than most dedicated OCR tools for Japanese text. | Folder | Purpose |
|---|---|
### How to Use It | `files/` | Place game files here before translating |
| `translated/` | Translated output appears here |
1. Press **Win+Shift+S** to open the Snipping Tool and take a screenshot of the untranslated text in-game. | `log/` | Translation logs and cache |
2. The screenshot opens in the Snipping Tool editor. Click the **Text Actions** button (the icon with lines of text) in the toolbar. | `modules/` | Engine-specific translation scripts |
3. The tool will detect and highlight all text in the image. You can now **click and drag** to select specific text, or click **Copy all text** to grab everything. | `gui/` | GUI source code |
4. Paste the copied Japanese text into VSCode's search (`Ctrl+Shift+F` to search across all files) to find exactly where it lives in the game data.
5. Fix or re-translate that file as needed. ---
### Why Snipping Tool? ## Finding Untranslated Text (Snipping Tool OCR)
- **Built into Windows 11** — no extra software to install. When playtesting a translated game, you'll inevitably find text that was missed or needs fixing. The fastest way to grab Japanese text from the screen and search for it in the game files is with the **Windows 11 Snipping Tool** — its built-in OCR is far better than most dedicated OCR tools for Japanese text.
- **Excellent Japanese OCR** — handles kanji, hiragana, and katakana very accurately, even from stylized game fonts.
- **Quick workflow** — screenshot → copy text → paste into search, all in a few seconds. ### How to Use It
> **Tip:** If you're on Windows 10 or the Text Actions button doesn't appear, make sure Snipping Tool is updated via the Microsoft Store. Alternatively, [ShareX](https://getsharex.com/) with its OCR feature is a good free option. 1. Press **Win+Shift+S** to open the Snipping Tool and take a screenshot of the untranslated text in-game.
2. The screenshot opens in the Snipping Tool editor. Click the **Text Actions** button (the icon with lines of text) in the toolbar.
--- 3. The tool will detect and highlight all text in the image. You can now **click and drag** to select specific text, or click **Copy all text** to grab everything.
4. Paste the copied Japanese text into VSCode's search (`Ctrl+Shift+F` to search across all files) to find exactly where it lives in the game data.
## RPG Maker Translation Workflow 5. Fix or re-translate that file as needed.
Here's the recommended step-by-step process for translating an RPG Maker MV/MZ game. This is also shown inside the GUI's RPG Maker tab. ### Why Snipping Tool?
| Step | Action | - **Built into Windows 11** — no extra software to install.
|------|--------| - **Excellent Japanese OCR** — handles kanji, hiragana, and katakana very accurately, even from stylized game fonts.
| **1** | **Parse speakers → vocab.txt** — Use the Parse Speakers feature to pull character names from the game files into `vocab.txt`. | - **Quick workflow** — screenshot → copy text → paste into search, all in a few seconds.
| **2** | **Identify speaker genders** — Figure out which characters are male/female and update `vocab.txt` accordingly. This helps the AI use correct pronouns. |
| **3** | **Translate Actors.json, MapInfos.json** — These are small files with character and map names. Good to do first. | > **Tip:** If you're on Windows 10 or the Text Actions button doesn't appear, make sure Snipping Tool is updated via the Microsoft Store. Alternatively, [ShareX](https://getsharex.com/) with its OCR feature is a good free option.
| **4** | **Translate Items, System, Weapons, etc.** — All the data files that aren't maps or events. Place them in `files/`, translate, then copy results back. |
| **5** | **Find speaker names** — Enable CODE 101 (Speakers), check for bracketed names, or use the "First Line = Speaker" option to capture speaker names properly. | ---
| **6** | **Replace `\n[0-999]` variables** — Some games use variable codes like `\n[1]` for character names. Replace these with the actual actor names so the AI can translate around them. |
| **7** | **Translate Maps & CommonEvents** — The bulk of the game's dialogue. Start with a small map to test, then do the rest. You can use **Estimate** in the GUI to check the cost before running. | ## RPG Maker Translation Workflow
| **8** | **Edit plugins for menus/text** — Some UI text lives in `plugins.js` or plugin parameters. You may need to manually translate these in a text editor. |
| **9** | **Translate CODE 122 vars, 356 plugins as needed** — Enable these codes in the RPG Maker tab if the game stores dialogue in variables or plugin commands. | Here's the recommended step-by-step process for translating an RPG Maker MV/MZ game. This is also shown inside the GUI's RPG Maker tab.
| **10** | **Playtest → find issues → fix → repeat** — Play through the game, screenshot any untranslated text, search for it in the game files, and re-translate as needed. |
| Step | Action |
> **Note:** Some text (e.g., CODE 122 variables) may only update when starting a new save file. |------|--------|
| **1** | **Parse speakers → vocab.txt** — Use the Parse Speakers feature to pull character names from the game files into `vocab.txt`. |
--- | **2** | **Identify speaker genders** — Figure out which characters are male/female and update `vocab.txt` accordingly. This helps the AI use correct pronouns. |
| **3** | **Translate Actors.json, MapInfos.json** — These are small files with character and map names. Good to do first. |
## Using Copilot & VSCode | **4** | **Translate Items, System, Weapons, etc.** — All the data files that aren't maps or events. Place them in `files/`, translate, then copy results back. |
| **5** | **Find speaker names** — Enable CODE 101 (Speakers), check for bracketed names, or use the "First Line = Speaker" option to capture speaker names properly. |
[VSCode](https://code.visualstudio.com/) is a free code editor, and with [GitHub Copilot](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot) you get an AI assistant built right into it. This is incredibly useful for translation work — you can ask the AI to help modify game files or even tweak the tool's modules without needing to know how to code. | **6** | **Replace `\n[0-999]` variables** — Some games use variable codes like `\n[1]` for character names. Replace these with the actual actor names so the AI can translate around them. |
| **7** | **Translate Maps & CommonEvents** — The bulk of the game's dialogue. Start with a small map to test, then do the rest. You can use **Estimate** in the GUI to check the cost before running. |
### Setup | **8** | **Edit plugins for menus/text** — Some UI text lives in `plugins.js` or plugin parameters. You may need to manually translate these in a text editor. |
| **9** | **Translate CODE 122 vars, 356 plugins as needed** — Enable these codes in the RPG Maker tab if the game stores dialogue in variables or plugin commands. |
1. Install [VSCode](https://code.visualstudio.com/). | **10** | **Playtest → find issues → fix → repeat** — Play through the game, screenshot any untranslated text, search for it in the game files, and re-translate as needed. |
2. Install the **GitHub Copilot** extension (`Ctrl+Shift+X` → search "GitHub Copilot").
3. Sign in with your GitHub account (Copilot has a free tier). > **Note:** Some text (e.g., CODE 122 variables) may only update when starting a new save file.
### Editing Game Files with AI ---
Open your game folder in VSCode (`Right Click` → `Open with Code`) and use Copilot Chat (`Ctrl+Shift+I`) to ask for changes. Examples: ## Using Copilot & VSCode
- *"Replace all `\n[1]` with `Shino` in this file"* [VSCode](https://code.visualstudio.com/) is a free code editor, and with [GitHub Copilot](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot) you get an AI assistant built right into it. This is incredibly useful for translation work — you can ask the AI to help modify game files or even tweak the tool's modules without needing to know how to code.
- *"Translate all the Japanese menu text in this plugins.js file to English"*
- *"This dialogue has broken line breaks — fix the formatting"* ### Setup
You can also select a block of text, right-click, and choose **Copilot → Fix / Explain / Modify** to work on just that selection. 1. Install [VSCode](https://code.visualstudio.com/).
2. Install the **GitHub Copilot** extension (`Ctrl+Shift+X` → search "GitHub Copilot").
### Modifying Tool Modules 3. Sign in with your GitHub account (Copilot has a free tier).
Open the DazedMTLTool folder in VSCode and ask Copilot to make changes to the translation modules. Examples: ### Editing Game Files with AI
- *"Add a new regex pattern to skip lines that start with //"* Open your game folder in VSCode (`Right Click` → `Open with Code`) and use Copilot Chat (`Ctrl+Shift+I`) to ask for changes. Examples:
- *"Change the wordwrap logic to break on full-width punctuation"*
- *"Explain what CODE 356 does in rpgmakermvmz.py"* - *"Replace all `\n[1]` with `Shino` in this file"*
- *"Translate all the Japanese menu text in this plugins.js file to English"*
Copilot can read the surrounding code and suggest context-aware edits — you just review and accept. This makes it easy to customize the tool for specific games without deep Python knowledge. - *"This dialogue has broken line breaks — fix the formatting"*
### Tips You can also select a block of text, right-click, and choose **Copilot → Fix / Explain / Modify** to work on just that selection.
- Use **Ctrl+Shift+I** to open Copilot Chat and ask questions about any file you have open. ### Modifying Tool Modules
- Use **Ctrl+I** for inline editing — select code, describe what you want changed, and Copilot will rewrite it in place.
- Use [Git](https://git-scm.com/) with your game folder so you can always undo changes if something breaks. The [GitLens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens) extension makes this even easier. Open the DazedMTLTool folder in VSCode and ask Copilot to make changes to the translation modules. Examples:
--- - *"Add a new regex pattern to skip lines that start with //"*
- *"Change the wordwrap logic to break on full-width punctuation"*
## Version Control with Git - *"Explain what CODE 356 does in rpgmakermvmz.py"*
Git tracks every change you make to your game files, so you can compare translations against the originals and roll back mistakes. This is optional but **highly recommended** — it has saved countless hours of work. Copilot can read the surrounding code and suggest context-aware edits — you just review and accept. This makes it easy to customize the tool for specific games without deep Python knowledge.
### Install Git ### Tips
1. Download and install [Git](https://git-scm.com/). The default settings during installation are fine. - Use **Ctrl+Shift+I** to open Copilot Chat and ask questions about any file you have open.
2. Open a terminal and verify it's installed: `git -v` - Use **Ctrl+I** for inline editing — select code, describe what you want changed, and Copilot will rewrite it in place.
- Use [Git](https://git-scm.com/) with your game folder so you can always undo changes if something breaks. The [GitLens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens) extension makes this even easier.
### Set Up Git in Your Game Folder
---
1. Open your **game folder** (where `Game.exe` lives) in VSCode — right-click the folder → **Open with Code**.
2. Open the terminal in VSCode (`Ctrl+`` ` ``) and run: ## Version Control with Git
```
git init Git tracks every change you make to your game files, so you can compare translations against the originals and roll back mistakes. This is optional but **highly recommended** — it has saved countless hours of work.
```
This creates a new Git repository in that folder. ### Install Git
### Create a .gitignore 1. Download and install [Git](https://git-scm.com/). The default settings during installation are fine.
2. Open a terminal and verify it's installed: `git -v`
Not every file needs to be tracked. Create a file called `.gitignore` in the game folder with contents like this:
### Set Up Git in Your Game Folder
```plaintext
# Ignore everything except text-based game files 1. Open your **game folder** (where `Game.exe` lives) in VSCode — right-click the folder → **Open with Code**.
*.* 2. Open the terminal in VSCode (`Ctrl+`` ` ``) and run:
# Allow these file types ```
!*.json git init
!*.txt ```
!*.js This creates a new Git repository in that folder.
!*.csv
!*.ks ### Create a .gitignore
!*.tjs
!*.rb Not every file needs to be tracked. Create a file called `.gitignore` in the game folder with contents like this:
!*.rvdata2
# Other useful files ```plaintext
!.gitignore # Ignore everything except text-based game files
``` *.*
# Allow these file types
This tells Git to only track the file types that matter for translation. !*.json
!*.txt
### Save Your First Commit !*.js
!*.csv
1. Click the **Source Control** icon on the left sidebar (or press `Ctrl+Shift+G`). !*.ks
2. You'll see all the game files listed. Type `Initial Commit` in the message box and click **Commit****Yes** (to stage all files). !*.tjs
3. Your original files are now saved. !*.rb
!*.rvdata2
### Create an "original" Branch # Other useful files
!.gitignore
This lets you always compare your translated files against the untouched originals. ```
1. Press `Ctrl+Shift+P` → type **Create Branch** → name it `original` → press Enter. This tells Git to only track the file types that matter for translation.
2. Press `Ctrl+Shift+P` → type **Checkout** → select `main` (or `master`).
### Save Your First Commit
Now you're back on the main branch. Any translations you make here can be compared against the `original` branch at any time.
1. Click the **Source Control** icon on the left sidebar (or press `Ctrl+Shift+G`).
### Comparing Changes 2. You'll see all the game files listed. Type `Initial Commit` in the message box and click **Commit****Yes** (to stage all files).
3. Your original files are now saved.
After translating and copying files back into the game folder:
### Create an "original" Branch
1. Open **Source Control** — you'll see all modified files listed.
2. Click any file to see a side-by-side diff of what changed. This lets you always compare your translated files against the untouched originals.
3. Commit your changes with a message like `Translated Items, Weapons, Actors`.
1. Press `Ctrl+Shift+P` → type **Create Branch** → name it `original` → press Enter.
To compare with the original untranslated files: 2. Press `Ctrl+Shift+P` → type **Checkout** → select `main` (or `master`).
- Right-click any file → **Open Changes****Open Changes with Branch** → select `original`.
Now you're back on the main branch. Any translations you make here can be compared against the `original` branch at any time.
### Recommended Extension
### Comparing Changes
Install [GitLens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens) (`Ctrl+Shift+X` → search "GitLens") for a much richer Git experience — commit history, file annotations, branch comparisons, and more.
After translating and copying files back into the game folder:
---
1. Open **Source Control** — you'll see all modified files listed.
## Troubleshooting 2. Click any file to see a side-by-side diff of what changed.
3. Commit your changes with a message like `Translated Items, Weapons, Actors`.
- **`START.bat` closes immediately** — Make sure Python 3.123.14 is installed and added to your PATH. Open a terminal and run `python -V` to check.
- **API errors** — Double-check your API key and organization in `.env`. Make sure you have credits/quota with your provider. To compare with the original untranslated files:
- Right-click any file → **Open Changes****Open Changes with Branch** → select `original`.
### Recommended Extension
Install [GitLens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens) (`Ctrl+Shift+X` → search "GitLens") for a much richer Git experience — commit history, file annotations, branch comparisons, and more.
---
## Troubleshooting
- **`START.bat` closes immediately** — Make sure Python 3.123.14 is installed and added to your PATH. Open a terminal and run `python -V` to check.
- **API errors** — Double-check your API key and organization in `.env`. Make sure you have credits/quota with your provider.
- **Missing dependencies** — Delete the `.venv` folder and run `START.bat` again. It will recreate the environment and reinstall everything. - **Missing dependencies** — Delete the `.venv` folder and run `START.bat` again. It will recreate the environment and reinstall everything.

245
START.sh Normal file
View file

@ -0,0 +1,245 @@
#!/usr/bin/env bash
# DazedMTLTool startup script for Linux/macOS
set -o pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
NEED_VENV_CREATE=0
VENV_DIR=""
CREATE_VENV_DIR=""
FOUND_PYTHON=""
pause_on_error() {
if [[ -t 0 ]]; then
read -r -p "Press Enter to exit..."
fi
}
die() {
echo "ERROR: $*"
pause_on_error
exit 1
}
python_version_ok() {
local version="$1"
local major="${version%%.*}"
local rest="${version#*.}"
local minor="${rest%%.*}"
[[ "$major" == "3" && "$minor" -ge 12 && "$minor" -lt 15 ]]
}
get_python_version() {
"$1" --version 2>&1 | awk '{print $2}'
}
check_python_version() {
[[ -n "$FOUND_PYTHON" ]] && return 0
local py="$1"
[[ -n "$py" && -x "$py" ]] || return 0
local ver
ver="$(get_python_version "$py" 2>/dev/null)" || return 0
if python_version_ok "$ver"; then
FOUND_PYTHON="$py"
fi
}
find_suitable_python() {
FOUND_PYTHON=""
local py candidate
while IFS= read -r py; do
check_python_version "$py"
[[ -n "$FOUND_PYTHON" ]] && return 0
done < <(type -a python3 python 2>/dev/null | awk '/ is / {print $NF}' | awk '!seen[$0]++')
for candidate in python3.14 python3.13 python3.12 python3 python; do
py="$(command -v "$candidate" 2>/dev/null || true)"
check_python_version "$py"
[[ -n "$FOUND_PYTHON" ]] && return 0
done
return 1
}
backup_venv() {
local target_dir="${1:-.venv}"
local bak_idx=1
while [[ -d "${target_dir}.bak_${bak_idx}" ]]; do
((bak_idx++))
done
if mv "$target_dir" "${target_dir}.bak_${bak_idx}"; then
echo "$target_dir renamed to ${target_dir}.bak_${bak_idx}"
else
echo "ERROR: Failed to back up $target_dir to ${target_dir}.bak_${bak_idx}."
echo "Please ensure no files are locked and try again."
return 1
fi
}
create_venv() {
[[ -n "$CREATE_VENV_DIR" ]] || CREATE_VENV_DIR=".venv"
echo "Creating new $CREATE_VENV_DIR using $FOUND_PYTHON ..."
if ! "$FOUND_PYTHON" -m venv "$CREATE_VENV_DIR"; then
die "Failed to create virtual environment."
fi
echo "Virtual environment created"
echo
VENV_DIR="$CREATE_VENV_DIR"
}
activate_venv() {
echo "Activating virtual environment..."
# shellcheck source=/dev/null
if source "$VENV_DIR/bin/activate"; then
echo "Virtual environment activated"
echo
return 0
fi
echo "ERROR: Failed to activate virtual environment at \"$VENV_DIR\"."
echo "Attempting to recreate the virtual environment with a compatible Python..."
CREATE_VENV_DIR="$VENV_DIR"
backup_venv "$VENV_DIR" || die "Failed to back up existing virtual environment."
if ! find_suitable_python; then
die "No suitable Python (>=3.12 and <3.15) found in PATH for recreation."
fi
echo "Recreating $CREATE_VENV_DIR using $FOUND_PYTHON ..."
if ! "$FOUND_PYTHON" -m venv "$CREATE_VENV_DIR"; then
die "Failed to create virtual environment during recreation."
fi
VENV_DIR="$CREATE_VENV_DIR"
echo "Retrying activation..."
# shellcheck source=/dev/null
if ! source "$VENV_DIR/bin/activate"; then
die "Activation failed after recreation."
fi
echo "Virtual environment activated"
echo
}
ensure_vocab_file() {
if [[ -f "vocab.txt" ]]; then
return 0
fi
if [[ -f "vocab.txt.example" ]]; then
echo "vocab.txt not found - creating from vocab.txt.example..."
if cp "vocab.txt.example" "vocab.txt"; then
echo "Created vocab.txt from vocab.txt.example"
else
echo "ERROR: Failed to copy vocab.txt.example to vocab.txt."
fi
else
echo "vocab.txt and vocab.txt.example not found - creating empty vocab.txt to avoid import errors..."
if : > "vocab.txt"; then
echo "Created empty vocab.txt"
else
echo "ERROR: Failed to create empty vocab.txt."
fi
fi
}
echo "=========================================="
echo " DazedMTLTool Startup Script"
echo "=========================================="
echo
echo "[1/4] Checking for a virtual environment..."
if [[ -d ".venv" ]]; then
VENV_DIR=".venv"
elif [[ -d "venv" ]]; then
VENV_DIR="venv"
fi
if [[ -n "$VENV_DIR" ]]; then
echo "$VENV_DIR found. Checking its Python version..."
venv_python="$VENV_DIR/bin/python"
if [[ ! -x "$venv_python" ]]; then
echo "ERROR: Python executable not found at \"$venv_python\"."
CREATE_VENV_DIR="$VENV_DIR"
backup_venv "$VENV_DIR" || die "Failed to back up existing virtual environment."
NEED_VENV_CREATE=1
else
venv_python_version="$(get_python_version "$venv_python" 2>/dev/null || true)"
if [[ -z "$venv_python_version" ]]; then
echo "ERROR: Could not determine Python version from \"$venv_python\"."
CREATE_VENV_DIR="$VENV_DIR"
backup_venv "$VENV_DIR" || die "Failed to back up existing virtual environment."
NEED_VENV_CREATE=1
else
echo "Detected Python version: $venv_python_version"
if python_version_ok "$venv_python_version"; then
echo "$VENV_DIR Python version $venv_python_version is compatible (>=3.12 and <3.15)."
else
echo "$VENV_DIR Python version $venv_python_version is not supported (requires >=3.12 and <3.15)"
echo "Backing up $VENV_DIR..."
CREATE_VENV_DIR="$VENV_DIR"
backup_venv "$VENV_DIR" || die "Failed to back up existing virtual environment."
NEED_VENV_CREATE=1
fi
fi
fi
else
echo "No existing virtual environment found."
CREATE_VENV_DIR=".venv"
NEED_VENV_CREATE=1
fi
echo
if [[ "$NEED_VENV_CREATE" -eq 1 ]]; then
echo "[2/4] Finding a compatible Python..."
if ! find_suitable_python; then
die "No suitable Python (>=3.12 and <3.15) found in PATH. Please install Python 3.12, 3.13, or 3.14 and ensure it is in your PATH."
fi
create_venv
fi
activate_venv
echo "Checking dependencies..."
echo "Checking if requirements are satisfied..."
if ! python -c "import PyQt5; import openai; import dotenv; import PIL; import anthropic; print('All dependencies satisfied')" >/dev/null 2>&1; then
echo "Upgrading pip..."
python -m pip install --upgrade pip >/dev/null 2>&1
echo "Installing/updating requirements..."
if ! pip install -r requirements.txt; then
die "Failed to install requirements."
fi
echo "Dependencies installed successfully"
else
echo "All dependencies are already satisfied"
fi
echo
echo "Checking RPG Maker Ace tools..."
if ! python -m util.ace.update_tools; then
echo "WARNING: Ace tool download failed. Ace translation features may not work until fixed."
fi
echo
echo "=========================================="
echo " Launching DazedMTLTool GUI..."
echo "=========================================="
echo
ensure_vocab_file
if ! python start_gui.py; then
echo
echo "ERROR: Failed to launch GUI."
echo "Check the error messages above."
pause_on_error
exit 1
fi
echo
echo "GUI closed successfully."

View file

@ -33,6 +33,7 @@ class ModelFetchThread(QThread):
"claude-opus-4-5", "claude-sonnet-4-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-sonnet-4-5", "claude-haiku-4-5",
"gemini-2.0-flash", "gemini-2.5-flash", "gemini-2.5-pro", "gemini-2.0-flash", "gemini-2.5-flash", "gemini-2.5-pro",
"deepseek-chat", "deepseek-chat",
"mistral-medium-3.5", # best quality/cost Mistral for translation (don't use -latest, it points at the older 3.1)
] ]
def __init__(self, api_key, api_url, parent=None): def __init__(self, api_key, api_url, parent=None):
@ -341,6 +342,7 @@ class ConfigTab(QWidget):
("Claude (Anthropic)", "https://api.anthropic.com/v1"), ("Claude (Anthropic)", "https://api.anthropic.com/v1"),
("Gemini", "https://generativelanguage.googleapis.com/v1beta/openai/"), ("Gemini", "https://generativelanguage.googleapis.com/v1beta/openai/"),
("DeepSeek", "https://api.deepseek.com/v1/"), ("DeepSeek", "https://api.deepseek.com/v1/"),
("Mistral", "https://api.mistral.ai/v1/"),
("Nvidia", "https://integrate.api.nvidia.com/v1/"), ("Nvidia", "https://integrate.api.nvidia.com/v1/"),
] ]
for _name, _url in _url_presets: for _name, _url in _url_presets:

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff