tooling/translation/README.md
AI-assisted translation workflow for SD Maid SE Android application with 64+ supported languages.
The script supports these main operations:
ai_translate.py - Main translation scriptbatches/ - Directory containing translation batch files (batch_*.json)README.md - This documentationFirst, remove any strings/plurals from the target file that no longer exist in the source:
python3 tooling/translation/ai_translate.py --source app/src/main/res/values/strings.xml --target app/src/main/res/values-lv/strings.xml --cleanup
This will:
Generate batch files containing strings that need translation:
python3 tooling/translation/ai_translate.py --source app/src/main/res/values/strings.xml --target app/src/main/res/values-lv/strings.xml --extract
This creates multiple batch_lv_XXX.json files with 50 entries each. Each batch file contains:
Open each batch file and add translations. For example, in batch_lv_001.json:
{
"type": "string",
"name": "onboarding_privacy_continue_action",
"source_text": "Continue",
"context": "...",
"translated_text": "Turpināt"
}
{
"type": "plural",
"name": "tasks_activity_active_notification_message",
"items": {
"one": "%d active task",
"other": "%d active tasks"
},
"context": "...",
"translated_items": {
"zero": "%d aktīvu uzdevumu",
"one": "%d aktīvs uzdevums",
"other": "%d aktīvi uzdevumi"
}
}
After translating a batch file, apply it to the target:
python3 tooling/translation/ai_translate.py --source app/src/main/res/values/strings.xml --target app/src/main/res/values-lv/strings.xml --apply batch_lv_001.json
This will:
Continue translating and applying batch files until all are processed.
The script automatically removes backup files after successful operations. To manually clean up old backup files:
python3 tooling/translation/ai_translate.py --source app/src/main/res/values/strings.xml --target app/src/main/res/values-lv/strings.xml --cleanup-backups
When using AI tools (ChatGPT, Claude, etc.) to translate the batch files:
Please translate the following Android app strings from English to [LANGUAGE].
Context: This is for "SD Maid SE", an Android storage cleaning application.
For each entry, please:
1. Add a "translated_text" field for string entries
2. Add a "translated_items" field for plural entries (maintaining proper plural forms for the target language)
3. Preserve any formatting like %d, %s, %1$s placeholders
4. Keep the meaning consistent with the app's context
Here's the batch file to translate:
[PASTE BATCH FILE CONTENT]
Each batch file contains:
language: Target language codebatch_id: Sequential batch numbersource_file: Path to source strings.xmltarget_file: Path to target strings.xmlentries: Array of translation entriesIf something goes wrong:
strings.backup_YYYYMMDD_HHMMSS.xmlAfter applying translations, verify the XML structure:
xmllint --noout app/src/main/res/values-lv/strings.xml
If the XML is malformed, restore from backup and try again.