Greetings, code chefs! Today, we’re serving up a hearty Python recipe to help you download, edit, and re-upload translations between your local machine and Transifex. Whether you’re fixing repeated phrases, standardizing terminology, or cleaning up target strings in bulk, this script will make your workflow smoother and tastier. Let’s get cooking!
Kitchen Prep: What You’ll Need
Before firing up the stove, make sure you have these ingredients ready:
-
Python 3 installed on your machine
-
Your Transifex API token
-
The slug for your organization and project(s)
-
A CSV file listing the project, resource, and language codes you want to process
-
The Transifex Python SDK installed
pip install transifex-python
Recipe Overview
This script:
-
Reads a CSV file to know which projects, resources, and languages to process
-
Downloads translations from Transifex as XLIFF files
-
Lets you define find-and-replace rules (exact or partial)
-
Applies those replacements to
<target>
elements only -
Uploads the cleaned-up translations back into Transifex
Example CSV File
Your CSV file should look like this:
project_slug,resource_slug,code
my_project,homepage,en
my_project,homepage,fr
my_project,about_page,es
Cooking Instructions: How to Run the Script
-
Save your CSV file (e.g.
translations.csv
). -
Open your terminal and navigate to the script’s folder.
-
Run the script:
python translation_cleanup.py translations.csv
-
Enter your API token and organization slug when prompted.
-
Choose your match type:
-
exact
→ replaces only if the whole string matches -
partial
→ replaces substrings inside longer texts
-
-
Add your find-and-replace pairs interactively (type
#DONE
when finished). -
Watch the script download translations, replace terms, and upload them back like a true sous-chef.
Troubleshooting
-
No matches found?
Double-check your CSV slugs and replacement text. -
Upload errors?
Make sure your API token has write access to the project. -
XLIFF parsing issues?
Check for namespace conflicts; the script handles most cases automatically.
Final Plating
Voilà ! Your translations are now updated, standardized, and neatly uploaded back to Transifex—without manual edits in the UI.
This recipe is perfect for:
-
Batch cleanups
-
Terminology enforcement
-
Fixing pesky text issues at scale
Bon appétit, and happy localizing!