#!/usr/bin/env python3 """ sync_cutscene_translations.py - Sync a cutscene config's strings into a translation file. Reads , collects every non-empty "speaker" and "text" string from its lines, and appends any string not already present as a "key" in as a new entry with an empty "en" slot ready for a translator to fill in. New entries are always appended at the end of the list so missing translations are easy to locate. Cutscene translations are intentionally kept in their own file/database, separate from dialogue translations - point at a dedicated file such as resources/dialogue/cutscene_translations.json. Usage: python sync_cutscene_translations.py """ import json import sys from translation_sync_common import sync_translations def collect_strings(cutscene_config: dict) -> list[str]: seen = set() ordered = [] def add(value): if value and value not in seen: seen.add(value) ordered.append(value) for cutscene in cutscene_config.get("cutscenes", []): for line in cutscene.get("lines", []): add(line.get("speaker", "")) add(line.get("text", "")) return ordered def sync(cutscene_path: str, translations_path: str) -> None: with open(cutscene_path, 'r', encoding='utf-8') as f: cutscene_config = json.load(f) sync_translations(collect_strings(cutscene_config), translations_path) if __name__ == '__main__': if len(sys.argv) != 3: print(f"Usage: {sys.argv[0]} ") sys.exit(1) sync(sys.argv[1], sys.argv[2])