Translate localization files (TRA) for Infinity Engine games like Baldur's Gate using multiple translation engines, process Russian text, handle dialogue files, and manage game mod translations.
This skill helps you work with TRA localization files and dialogue scripts for Infinity Engine games (Baldur's Gate, Icewind Dale, etc.). It provides translation, text processing, and dialogue management capabilities for game modding projects.
TRA files contain localization strings in these formats:
```
@1 = ~English text here~
@2 = "Another format with quotes"
```
Scripts automatically detect delimiters (`~~` or `""`) and preserve formatting. Encoding is auto-detected using chardet (UTF-8, CP1251, CP1252, etc.).
Before working with TRA files, ensure all dependencies are installed:
```bash
pip install googletrans==4.0.0rc1 textblob pycld2 google-cloud-translate deepl colorama click chardet levenshtein nltk antlr4-python3-runtime
```
If a virtual environment exists in `venv/`, activate it first:
```bash
source venv/bin/activate
```
Use `translate_tra.py` for basic TRA file translation:
```bash
python3 translate_tra.py infile.tra [--engine=googletrans|deepl|googlecloud] [--lang=ru] [--out=output.tra]
```
**Options:**
**Default engine is DeepL**, which provides high-quality translations but requires an API key.
For Russian translations, use `yo_making.py` to convert е to ё based on dictionaries:
```bash
python3 yo_making.py infile.tra [--out=output.tra] [--always-no]
```
This uses two dictionaries:
Use `--always-no` to skip interactive prompts for ambiguous cases.
For dialogue-heavy mods, use the grammar-based parser to extract dialogues:
```bash
python3 parse_d_grammar.py d_folder tra_folder output_folder
```
**What this does:**
**D File Constructs Supported:**
Translate extracted dialogues using local LLM (Ollama):
```bash
python3 translate_dialogs.py [source_folder] [--target target_folder] [--model model_name]
```
**Features:**
**Dictionary Features:**
Apply translated dialogues back to TRA files:
```bash
python3 update_tra_from_csv.py tra_folder csv_folder [--output output_folder]
```
**Behavior:**
**Find Similar Lines:**
```bash
python3 find_closest_lines_in_tra.py
```
Finds similar lines between TRA files using Levenshtein distance.
**Extract Specific Lines:**
```bash
python3 extract_lines_tra.py
```
Extracts specific lines from TRA files based on criteria.
**Extract Actor Names:**
```bash
python3 extract_actors_using_grammar.py
```
Extracts actor names from D files using the grammar parser.
**Generate Renaming Tables:**
```bash
python3 generate_global_renaming_table.py
```
Creates renaming tables for game files with prefixes.
**Encoding Conversion:**
```bash
./utf8_2_cp1251.sh # Convert UTF-8 to CP1251
./cp1251_2_utf8.sh # Convert CP1251 to UTF-8
```
1. Extract dialogues: `parse_d_grammar.py d_folder tra_folder csv_output`
2. Translate dialogues: `translate_dialogs.py csv_output --target translated_csv`
3. Update TRA files: `update_tra_from_csv.py tra_folder translated_csv --output updated_tra`
4. Fix Russian ё: `yo_making.py updated_tra/*.tra`
This workflow ensures proper dialogue flow tracking, context-aware translations, and correct formatting preservation.
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/translate-tra-files-for-infinity-engine-mods/raw