toto-script-tool 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- toto_script_tool-1.0.0/.github/workflows/publish.yml +53 -0
- toto_script_tool-1.0.0/.github/workflows/test.yml +25 -0
- toto_script_tool-1.0.0/.gitignore +30 -0
- toto_script_tool-1.0.0/CHANGELOG.md +20 -0
- toto_script_tool-1.0.0/LICENSE +7 -0
- toto_script_tool-1.0.0/Makefile +34 -0
- toto_script_tool-1.0.0/PKG-INFO +122 -0
- toto_script_tool-1.0.0/README.md +99 -0
- toto_script_tool-1.0.0/pyproject.toml +203 -0
- toto_script_tool-1.0.0/scripts/mgos_disasm.py +295 -0
- toto_script_tool-1.0.0/src/toto/SilkyEngineMES.py +54 -0
- toto_script_tool-1.0.0/src/toto/__about__.py +1 -0
- toto_script_tool-1.0.0/src/toto/__init__.py +1 -0
- toto_script_tool-1.0.0/src/toto/filetypes/AdvHdWs2.py +709 -0
- toto_script_tool-1.0.0/src/toto/filetypes/AgsdSpt.py +359 -0
- toto_script_tool-1.0.0/src/toto/filetypes/Anim.py +231 -0
- toto_script_tool-1.0.0/src/toto/filetypes/DxLib.py +118 -0
- toto_script_tool-1.0.0/src/toto/filetypes/KiriKiriScriptV2.py +224 -0
- toto_script_tool-1.0.0/src/toto/filetypes/Mgos.py +380 -0
- toto_script_tool-1.0.0/src/toto/filetypes/TranslatableFile.py +98 -0
- toto_script_tool-1.0.0/src/toto/filetypes/__init__.py +0 -0
- toto_script_tool-1.0.0/src/toto/tests/__init__.py +0 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/AGSD/__init__.py +0 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/AGSD/test_agsd_spt.py +466 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/AGSD/test_nonfree_roundtrip.py +38 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/AdvHdWs2/__init__.py +0 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/AdvHdWs2/test_advhd_ws2.py +446 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/AdvHdWs2/test_nonfree_roundtrip.py +38 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/Anim/__init__.py +0 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/Anim/test_anim.py +184 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/Anim/test_nonfree_roundtrip.py +52 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/DxLib/__init__.py +0 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/DxLib/test_nonfree_roundtrip.py +39 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/DxLib/test_roundtrip.py +111 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/__init__.py +0 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/samples/basic_grouping.ks +10 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/samples/group_edges.ks +9 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/samples/has_text.ks +3 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/samples/leading_whitespace.ks +5 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/samples/minimal/minimal.ks +6 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/samples/minimal/remaining.ks +6 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/samples/no_text.ks +6 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/samples/realistic_japanese.ks +16 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/samples/single_line_dialogue.ks +3 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/samples/utf16_bom.ks +0 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/samples/wrapping.ks +3 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/test_insertion.py +364 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/test_nonfree_roundtrip.py +50 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/KiriKiriScriptV2/test_roundtrip.py +33 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/Mgos/__init__.py +0 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/Mgos/test_mgos.py +853 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/Mgos/test_nonfree_roundtrip.py +38 -0
- toto_script_tool-1.0.0/src/toto/tests/filetypes/__init__.py +0 -0
- toto_script_tool-1.0.0/src/toto/tests/test_extract_paths.py +172 -0
- toto_script_tool-1.0.0/src/toto/tests/test_ignore_line_regex.py +257 -0
- toto_script_tool-1.0.0/src/toto/tests/test_skip_identical.py +127 -0
- toto_script_tool-1.0.0/src/toto/tests/test_wrapping.py +101 -0
- toto_script_tool-1.0.0/src/toto/toto.py +207 -0
- toto_script_tool-1.0.0/src/toto/util.py +89 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
strategy:
|
|
11
|
+
matrix:
|
|
12
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v5
|
|
15
|
+
- uses: actions/setup-python@v6
|
|
16
|
+
with:
|
|
17
|
+
python-version: ${{ matrix.python-version }}
|
|
18
|
+
- name: Install Hatch
|
|
19
|
+
run: pip install hatch
|
|
20
|
+
- name: Run tests
|
|
21
|
+
run: hatch run test
|
|
22
|
+
- name: Check style
|
|
23
|
+
run: hatch run lint:style
|
|
24
|
+
|
|
25
|
+
build:
|
|
26
|
+
needs: test
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v5
|
|
30
|
+
- uses: actions/setup-python@v6
|
|
31
|
+
with:
|
|
32
|
+
python-version: "3.12"
|
|
33
|
+
- name: Install Hatch
|
|
34
|
+
run: pip install hatch
|
|
35
|
+
- name: Build
|
|
36
|
+
run: hatch build
|
|
37
|
+
- uses: actions/upload-artifact@v5
|
|
38
|
+
with:
|
|
39
|
+
name: dist
|
|
40
|
+
path: dist/
|
|
41
|
+
|
|
42
|
+
publish:
|
|
43
|
+
needs: build
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
environment: pypi
|
|
46
|
+
permissions:
|
|
47
|
+
id-token: write
|
|
48
|
+
steps:
|
|
49
|
+
- uses: actions/download-artifact@v5
|
|
50
|
+
with:
|
|
51
|
+
name: dist
|
|
52
|
+
path: dist/
|
|
53
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v5
|
|
17
|
+
- uses: actions/setup-python@v6
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python-version }}
|
|
20
|
+
- name: Install Hatch
|
|
21
|
+
run: pip install hatch
|
|
22
|
+
- name: Run tests
|
|
23
|
+
run: hatch run test
|
|
24
|
+
- name: Check style
|
|
25
|
+
run: hatch run lint:style
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Virtual environments
|
|
2
|
+
.env/
|
|
3
|
+
.venv/
|
|
4
|
+
|
|
5
|
+
# Python
|
|
6
|
+
__pycache__/
|
|
7
|
+
*.py[cod]
|
|
8
|
+
*.egg-info/
|
|
9
|
+
*.egg
|
|
10
|
+
*.so
|
|
11
|
+
dist/
|
|
12
|
+
build/
|
|
13
|
+
|
|
14
|
+
# Testing
|
|
15
|
+
.pytest_cache/
|
|
16
|
+
.coverage
|
|
17
|
+
htmlcov/
|
|
18
|
+
|
|
19
|
+
# IDE
|
|
20
|
+
.idea/
|
|
21
|
+
.vscode/
|
|
22
|
+
*.swp
|
|
23
|
+
*.swo
|
|
24
|
+
|
|
25
|
+
# OS
|
|
26
|
+
.DS_Store
|
|
27
|
+
Thumbs.db
|
|
28
|
+
|
|
29
|
+
# Nonfree test samples (real game data, not distributable)
|
|
30
|
+
src/toto/tests/**/nonfree/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [1.0.0] — 2026-04-17
|
|
4
|
+
|
|
5
|
+
Initial public release. CLI tool for extracting and reinserting translatable text in visual novel scripts.
|
|
6
|
+
|
|
7
|
+
### Supported engines
|
|
8
|
+
|
|
9
|
+
- **KiriKiri**
|
|
10
|
+
- **DxLib**
|
|
11
|
+
- **Anim**
|
|
12
|
+
- **mgos** (μ-GameOperationSystem)
|
|
13
|
+
- **AGSD** (NicotineSoft)
|
|
14
|
+
- **AdvHD** (Willplus)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- Plugin-based format handler system via Python entry points
|
|
19
|
+
- `extract` command with custom regex to ignore certain lines, and ability to unwrap text on extraction
|
|
20
|
+
- `insert` command with support for automatic wrapping of text
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2026 Kenkyuuka <kenkyuuka@proton.me>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.PHONY: test test-nonfree cov lint fmt typecheck check reinstall
|
|
2
|
+
|
|
3
|
+
## Testing
|
|
4
|
+
test: ## Run all tests
|
|
5
|
+
hatch run test
|
|
6
|
+
|
|
7
|
+
test-nonfree: ## Run nonfree tests only
|
|
8
|
+
hatch run test-nonfree
|
|
9
|
+
|
|
10
|
+
cov: ## Run tests with coverage report
|
|
11
|
+
hatch run cov
|
|
12
|
+
|
|
13
|
+
## Linting & Formatting
|
|
14
|
+
lint: ## Run ruff + black check
|
|
15
|
+
hatch run lint:style
|
|
16
|
+
|
|
17
|
+
fmt: ## Auto-format (black + ruff --fix)
|
|
18
|
+
hatch run lint:fmt
|
|
19
|
+
|
|
20
|
+
typecheck: ## Run mypy type checking
|
|
21
|
+
hatch run lint:typing
|
|
22
|
+
|
|
23
|
+
check: ## Run all lint + type checks
|
|
24
|
+
hatch run lint:all
|
|
25
|
+
|
|
26
|
+
## Environment
|
|
27
|
+
reinstall: ## Recreate hatch env (picks up new entry points)
|
|
28
|
+
hatch env prune && hatch env create
|
|
29
|
+
|
|
30
|
+
## Help
|
|
31
|
+
help: ## Show this help
|
|
32
|
+
@grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) | awk -F ':.*## ' '{printf " \033[36m%-16s\033[0m %s\n", $$1, $$2}'
|
|
33
|
+
|
|
34
|
+
.DEFAULT_GOAL := help
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: toto-script-tool
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Visual novel script localization tool
|
|
5
|
+
Project-URL: Homepage, https://github.com/kenkyuuka/toto
|
|
6
|
+
Project-URL: Repository, https://github.com/kenkyuuka/toto
|
|
7
|
+
Project-URL: Issues, https://github.com/kenkyuuka/toto/issues
|
|
8
|
+
Author-email: Kenkyuuka <kenkyuuka@proton.me>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
18
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: chardet
|
|
21
|
+
Requires-Dist: click
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# toto
|
|
25
|
+
|
|
26
|
+
A visual novel script localization tool. toto extracts translatable text from various VN engine script formats, manages translations, and reinserts translated text back into script files.
|
|
27
|
+
|
|
28
|
+
## Supported engines
|
|
29
|
+
|
|
30
|
+
| Engine | Handler | File types |
|
|
31
|
+
|--------|---------|------------|
|
|
32
|
+
| KiriKiri | `kirikiri` | `.ks`, `.soc` |
|
|
33
|
+
| DxLib | `dxlib` | binary scripts |
|
|
34
|
+
| Anim | `anim` | `.dat` |
|
|
35
|
+
| mgos (μ-GameOperationSystem) | `mgos` | `.o` |
|
|
36
|
+
| AGSD (NicotineSoft) | `agsd` | `.spt` |
|
|
37
|
+
| AdvHD (Willplus) | `advhd` | `.ws2` |
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install toto-script-tool
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Or for development:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install hatch
|
|
49
|
+
hatch env create
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
### Extract
|
|
55
|
+
|
|
56
|
+
Extract translatable text from script files:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
toto extract --filetype=kirikiri path/to/scripts/
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Options:
|
|
63
|
+
- `--filetype` (required) — engine format (see table above)
|
|
64
|
+
- `--outpath` — where to write translation files (default: `./project/source/`)
|
|
65
|
+
- `--workpath` — where to store intermediate files (default: `./working/`)
|
|
66
|
+
- `--codec` — force a specific text encoding
|
|
67
|
+
- `--ignore-line-regex` — regex pattern to skip matching lines (repeatable)
|
|
68
|
+
- `--unwrap` — remove inline line breaks from extracted text for re-wrapping on insertion (supported formats: `agsd`)
|
|
69
|
+
|
|
70
|
+
### Insert
|
|
71
|
+
|
|
72
|
+
Reinsert translated text into script files:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
toto insert --filetype=kirikiri path/to/translations/
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Options:
|
|
79
|
+
- `--filetype` (required) — engine format
|
|
80
|
+
- `--outpath` — where to write patched scripts (default: `./patch/`)
|
|
81
|
+
- `--workpath` — intermediate file directory (default: `./working/`)
|
|
82
|
+
- `--width` — line width for text wrapping (default: 60; supported formats: `agsd`, `kirikiri`)
|
|
83
|
+
- `--wrap` — wrapping mode (supported formats: `agsd`, `kirikiri`)
|
|
84
|
+
- `--codec` — force output encoding
|
|
85
|
+
- `--skip-identical` — skip files where all translations match the original
|
|
86
|
+
|
|
87
|
+
## Workflow
|
|
88
|
+
|
|
89
|
+
1. **Extract** translatable text from original scripts. This produces translation files (plain text, one line per string) and intermediate files with placeholder tokens.
|
|
90
|
+
2. **Translate** the extracted text files — by hand, with MT, or however you like.
|
|
91
|
+
3. **Insert** the translations back. toto substitutes translated text into the intermediate files to produce patched scripts ready for use.
|
|
92
|
+
|
|
93
|
+
## Related tools
|
|
94
|
+
|
|
95
|
+
[tamago](https://github.com/kenkyuuka/tamago) can create and extract archive files for VN engines supported by toto, completing the translation workflow: unpack archives with tamago, extract and translate scripts with toto, then repack with tamago.
|
|
96
|
+
|
|
97
|
+
## Adding format handlers
|
|
98
|
+
|
|
99
|
+
toto uses a plugin system based on Python entry points. To add support for a new engine format:
|
|
100
|
+
|
|
101
|
+
1. Create a handler class that extends `toto.filetypes.TranslatableFile.TranslatableFile`
|
|
102
|
+
2. Implement `get_paths()`, `extract_lines()`, and `insert_lines()`
|
|
103
|
+
3. Register it as an entry point under `toto.filetypes` in `pyproject.toml`
|
|
104
|
+
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Run tests
|
|
109
|
+
hatch run test
|
|
110
|
+
|
|
111
|
+
# Run a specific test
|
|
112
|
+
hatch run test -- -k "test_name"
|
|
113
|
+
|
|
114
|
+
# Lint and format
|
|
115
|
+
hatch run lint:style # check
|
|
116
|
+
hatch run lint:fmt # auto-format
|
|
117
|
+
hatch run lint:typing # mypy
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# toto
|
|
2
|
+
|
|
3
|
+
A visual novel script localization tool. toto extracts translatable text from various VN engine script formats, manages translations, and reinserts translated text back into script files.
|
|
4
|
+
|
|
5
|
+
## Supported engines
|
|
6
|
+
|
|
7
|
+
| Engine | Handler | File types |
|
|
8
|
+
|--------|---------|------------|
|
|
9
|
+
| KiriKiri | `kirikiri` | `.ks`, `.soc` |
|
|
10
|
+
| DxLib | `dxlib` | binary scripts |
|
|
11
|
+
| Anim | `anim` | `.dat` |
|
|
12
|
+
| mgos (μ-GameOperationSystem) | `mgos` | `.o` |
|
|
13
|
+
| AGSD (NicotineSoft) | `agsd` | `.spt` |
|
|
14
|
+
| AdvHD (Willplus) | `advhd` | `.ws2` |
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install toto-script-tool
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or for development:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install hatch
|
|
26
|
+
hatch env create
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Extract
|
|
32
|
+
|
|
33
|
+
Extract translatable text from script files:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
toto extract --filetype=kirikiri path/to/scripts/
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Options:
|
|
40
|
+
- `--filetype` (required) — engine format (see table above)
|
|
41
|
+
- `--outpath` — where to write translation files (default: `./project/source/`)
|
|
42
|
+
- `--workpath` — where to store intermediate files (default: `./working/`)
|
|
43
|
+
- `--codec` — force a specific text encoding
|
|
44
|
+
- `--ignore-line-regex` — regex pattern to skip matching lines (repeatable)
|
|
45
|
+
- `--unwrap` — remove inline line breaks from extracted text for re-wrapping on insertion (supported formats: `agsd`)
|
|
46
|
+
|
|
47
|
+
### Insert
|
|
48
|
+
|
|
49
|
+
Reinsert translated text into script files:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
toto insert --filetype=kirikiri path/to/translations/
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Options:
|
|
56
|
+
- `--filetype` (required) — engine format
|
|
57
|
+
- `--outpath` — where to write patched scripts (default: `./patch/`)
|
|
58
|
+
- `--workpath` — intermediate file directory (default: `./working/`)
|
|
59
|
+
- `--width` — line width for text wrapping (default: 60; supported formats: `agsd`, `kirikiri`)
|
|
60
|
+
- `--wrap` — wrapping mode (supported formats: `agsd`, `kirikiri`)
|
|
61
|
+
- `--codec` — force output encoding
|
|
62
|
+
- `--skip-identical` — skip files where all translations match the original
|
|
63
|
+
|
|
64
|
+
## Workflow
|
|
65
|
+
|
|
66
|
+
1. **Extract** translatable text from original scripts. This produces translation files (plain text, one line per string) and intermediate files with placeholder tokens.
|
|
67
|
+
2. **Translate** the extracted text files — by hand, with MT, or however you like.
|
|
68
|
+
3. **Insert** the translations back. toto substitutes translated text into the intermediate files to produce patched scripts ready for use.
|
|
69
|
+
|
|
70
|
+
## Related tools
|
|
71
|
+
|
|
72
|
+
[tamago](https://github.com/kenkyuuka/tamago) can create and extract archive files for VN engines supported by toto, completing the translation workflow: unpack archives with tamago, extract and translate scripts with toto, then repack with tamago.
|
|
73
|
+
|
|
74
|
+
## Adding format handlers
|
|
75
|
+
|
|
76
|
+
toto uses a plugin system based on Python entry points. To add support for a new engine format:
|
|
77
|
+
|
|
78
|
+
1. Create a handler class that extends `toto.filetypes.TranslatableFile.TranslatableFile`
|
|
79
|
+
2. Implement `get_paths()`, `extract_lines()`, and `insert_lines()`
|
|
80
|
+
3. Register it as an entry point under `toto.filetypes` in `pyproject.toml`
|
|
81
|
+
|
|
82
|
+
## Development
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Run tests
|
|
86
|
+
hatch run test
|
|
87
|
+
|
|
88
|
+
# Run a specific test
|
|
89
|
+
hatch run test -- -k "test_name"
|
|
90
|
+
|
|
91
|
+
# Lint and format
|
|
92
|
+
hatch run lint:style # check
|
|
93
|
+
hatch run lint:fmt # auto-format
|
|
94
|
+
hatch run lint:typing # mypy
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
MIT
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "toto-script-tool"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Visual novel script localization tool"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
keywords = []
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Kenkyuuka", email = "kenkyuuka@proton.me" },
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Programming Language :: Python",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.14",
|
|
23
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
24
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
25
|
+
]
|
|
26
|
+
dependencies = ["Click", "chardet"]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://github.com/kenkyuuka/toto"
|
|
30
|
+
Repository = "https://github.com/kenkyuuka/toto"
|
|
31
|
+
Issues = "https://github.com/kenkyuuka/toto/issues"
|
|
32
|
+
|
|
33
|
+
[project.scripts]
|
|
34
|
+
toto = "toto.toto:cli"
|
|
35
|
+
|
|
36
|
+
[project.entry-points."toto.filetypes"]
|
|
37
|
+
dxlib = "toto.filetypes.DxLib:DxLib"
|
|
38
|
+
anim = "toto.filetypes.Anim:Anim"
|
|
39
|
+
kirikiri = "toto.filetypes.KiriKiriScriptV2:KiriKiriScript"
|
|
40
|
+
mgos = "toto.filetypes.Mgos:Mgos"
|
|
41
|
+
agsd = "toto.filetypes.AgsdSpt:AgsdSpt"
|
|
42
|
+
advhd = "toto.filetypes.AdvHdWs2:AdvHdWs2"
|
|
43
|
+
|
|
44
|
+
[tool.hatch.build.targets.wheel]
|
|
45
|
+
packages = ["src/toto"]
|
|
46
|
+
exclude = ["src/toto/tests"]
|
|
47
|
+
|
|
48
|
+
[tool.hatch.version]
|
|
49
|
+
path = "src/toto/__about__.py"
|
|
50
|
+
|
|
51
|
+
[tool.hatch.envs.default]
|
|
52
|
+
dependencies = [
|
|
53
|
+
"coverage[toml]>=6.5",
|
|
54
|
+
"pytest",
|
|
55
|
+
"pytest-cov",
|
|
56
|
+
"pytest-xdist[psutil]",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
[tool.hatch.envs.default.scripts]
|
|
60
|
+
test = "pytest src/toto/tests -n auto --maxprocesses 8 {args}"
|
|
61
|
+
test-nonfree = "pytest src/toto/tests -n auto --maxprocesses 8 -m nonfree {args}"
|
|
62
|
+
cov = "pytest src/toto/tests -n auto --maxprocesses 8 --cov --cov-report=term-missing {args}"
|
|
63
|
+
|
|
64
|
+
[tool.hatch.envs.hatch-test]
|
|
65
|
+
|
|
66
|
+
[[tool.hatch.envs.all.matrix]]
|
|
67
|
+
python = ["3.11", "3.12", "3.13", "3.14"]
|
|
68
|
+
|
|
69
|
+
[tool.hatch.envs.lint]
|
|
70
|
+
dependencies = [
|
|
71
|
+
"black>=23.1.0",
|
|
72
|
+
"mypy>=1.0.0",
|
|
73
|
+
"pytest",
|
|
74
|
+
"ruff>=0.0.243",
|
|
75
|
+
]
|
|
76
|
+
[tool.hatch.envs.lint.scripts]
|
|
77
|
+
typing = "mypy --install-types --non-interactive {args:src/toto}"
|
|
78
|
+
style = [
|
|
79
|
+
"ruff check {args:.}",
|
|
80
|
+
"black --check --diff {args:.}",
|
|
81
|
+
]
|
|
82
|
+
fmt = [
|
|
83
|
+
"black {args:.}",
|
|
84
|
+
"ruff check --fix {args:.}",
|
|
85
|
+
"style",
|
|
86
|
+
]
|
|
87
|
+
all = [
|
|
88
|
+
"style",
|
|
89
|
+
"typing",
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
[tool.black]
|
|
93
|
+
target-version = ["py311"]
|
|
94
|
+
line-length = 120
|
|
95
|
+
skip-string-normalization = true
|
|
96
|
+
|
|
97
|
+
[tool.ruff]
|
|
98
|
+
target-version = "py311"
|
|
99
|
+
line-length = 120
|
|
100
|
+
extend-exclude = ["scripts"]
|
|
101
|
+
[tool.ruff.lint]
|
|
102
|
+
select = [
|
|
103
|
+
"A",
|
|
104
|
+
"ARG",
|
|
105
|
+
"B",
|
|
106
|
+
"C",
|
|
107
|
+
"DTZ",
|
|
108
|
+
"E",
|
|
109
|
+
"EM",
|
|
110
|
+
"F",
|
|
111
|
+
"FBT",
|
|
112
|
+
"I",
|
|
113
|
+
"ICN",
|
|
114
|
+
"ISC",
|
|
115
|
+
"N",
|
|
116
|
+
"PLC",
|
|
117
|
+
"PLE",
|
|
118
|
+
"PLR",
|
|
119
|
+
"PLW",
|
|
120
|
+
"Q",
|
|
121
|
+
"RUF",
|
|
122
|
+
"S",
|
|
123
|
+
"T",
|
|
124
|
+
"TID",
|
|
125
|
+
"UP",
|
|
126
|
+
"W",
|
|
127
|
+
"YTT",
|
|
128
|
+
]
|
|
129
|
+
ignore = [
|
|
130
|
+
# Allow boolean positional values in function calls, like `dict.get(... True)`
|
|
131
|
+
"FBT002", "FBT003",
|
|
132
|
+
# Ignore checks for possible passwords
|
|
133
|
+
"S105", "S106", "S107",
|
|
134
|
+
# shelve/pickle used intentionally by the CLI
|
|
135
|
+
"S301",
|
|
136
|
+
# Ignore complexity
|
|
137
|
+
"C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915",
|
|
138
|
+
# Magic values are standard in binary format parsing (0xFF, 0x81, etc.)
|
|
139
|
+
"PLR2004",
|
|
140
|
+
# Quote style managed by black (skip-string-normalization = true)
|
|
141
|
+
"Q000",
|
|
142
|
+
# Allow string/f-string literals in exceptions (all three forms)
|
|
143
|
+
"EM101", "EM102", "EM103",
|
|
144
|
+
# Allow implicit string concatenation on one line
|
|
145
|
+
"ISC001",
|
|
146
|
+
# Allow print() in CLI and diagnostic code
|
|
147
|
+
"T201",
|
|
148
|
+
# Allow conditional/lazy imports not at top level
|
|
149
|
+
"PLC0415",
|
|
150
|
+
# Fullwidth Japanese characters are intentional (VN localization tool)
|
|
151
|
+
"RUF001", "RUF002", "RUF003",
|
|
152
|
+
# CamelCase module names are the project convention
|
|
153
|
+
"N999",
|
|
154
|
+
# Unused args from interface conformance (width, wrap in handlers)
|
|
155
|
+
"ARG003", "ARG004",
|
|
156
|
+
# Unnecessary dict/list constructor calls — style preference
|
|
157
|
+
"C408",
|
|
158
|
+
]
|
|
159
|
+
unfixable = [
|
|
160
|
+
# Don't touch unused imports
|
|
161
|
+
"F401",
|
|
162
|
+
]
|
|
163
|
+
|
|
164
|
+
[tool.ruff.lint.isort]
|
|
165
|
+
known-first-party = ["toto"]
|
|
166
|
+
|
|
167
|
+
[tool.ruff.lint.flake8-tidy-imports]
|
|
168
|
+
ban-relative-imports = "all"
|
|
169
|
+
|
|
170
|
+
[tool.ruff.lint.per-file-ignores]
|
|
171
|
+
# Tests can use magic values, assertions, and relative imports
|
|
172
|
+
"**/tests/**/*" = ["ARG002", "F401", "RUF059", "S101", "TID252"]
|
|
173
|
+
"**/src/**/*" = ["A002", "ARG002", "RUF023", "S101", "TID252"]
|
|
174
|
+
|
|
175
|
+
[tool.mypy]
|
|
176
|
+
# Handler subclasses intentionally extend base class signatures with extra kwargs;
|
|
177
|
+
# the base class is for documentation, not polymorphic dispatch.
|
|
178
|
+
disable_error_code = ["override"]
|
|
179
|
+
|
|
180
|
+
[tool.pytest.ini_options]
|
|
181
|
+
markers = [
|
|
182
|
+
"unit: pure logic tests with no filesystem or external dependencies",
|
|
183
|
+
"integration: tests that read/write files or use the detection pipeline",
|
|
184
|
+
"nonfree: tests that require real game data in nonfree/ directories",
|
|
185
|
+
]
|
|
186
|
+
|
|
187
|
+
[tool.coverage.run]
|
|
188
|
+
source_pkgs = ["toto"]
|
|
189
|
+
branch = true
|
|
190
|
+
parallel = true
|
|
191
|
+
omit = [
|
|
192
|
+
"src/toto/__about__.py",
|
|
193
|
+
]
|
|
194
|
+
|
|
195
|
+
[tool.coverage.paths]
|
|
196
|
+
toto = ["src/toto", "*/toto/src/toto"]
|
|
197
|
+
|
|
198
|
+
[tool.coverage.report]
|
|
199
|
+
exclude_lines = [
|
|
200
|
+
"no cov",
|
|
201
|
+
"if __name__ == .__main__.:",
|
|
202
|
+
"if TYPE_CHECKING:",
|
|
203
|
+
]
|