Easily automate translation for iOS localization files (.strings) using Google Translate API via googletrans.
This script saves hours of manual work by automatically generating translated .strings files for multiple languages.
- ✅ Automatically translates your base
Localizable.stringsfile - 🌍 Supports multiple target languages
- ⚡ Fast translation with progress tracking (
tqdm) - 🧩 Simple configuration for any iOS project structure
- ⚡ One-click updates for all localizations — no need for extra packages
You can either:
- Click Code → Download ZIP on GitHub, then extract the files, or
- Clone the repository using GitHub Desktop or command line:
git clone https://github.com/MianMHaroon/translate_strings_xcode-iOS.gitPlace the file translate_strings.py in the root folder of your iOS project.
Your project structure should look like this:
/MyProject
├── translate_strings.py
└── (your existing folders and files)
Ensure you have Python 3.x installed. You can download it from: https://www.python.org/downloads
To verify installation, open your terminal and run:
python --versionYou should see something like:
Python 3.10.12
Open your terminal and run:
pip install googletrans==4.0.0-rc1 tqdmThis installs:
- googletrans → for automatic translations via Google Translate
- tqdm → for displaying progress bars during translation
Option 1 — Use pip3 (macOS/Linux):
pip3 install googletrans==4.0.0-rc1 tqdmOption 2 — Use Python’s module installer:
python -m pip install googletrans==4.0.0-rc1 tqdmOption 3 — Install latest working version from GitHub:
pip install git+https://github.com/ssut/py-googletrans.git✅ Tip: Upgrade pip and setuptools if you face issues:
pip install --upgrade pip setuptoolsOpen translate_strings.py in a text editor and update:
PROJECT_PATH = "./aichat3/Resources/Localization"
BASE_FILENAME = "Localizable.strings"Example:
PROJECT_PATH = "./MyApp/Resources/Localization"
BASE_FILENAME = "Base.strings"Note:
PROJECT_PATHshould point to the folder containing all.lprojfolders (e.g.,en.lproj,fr.lproj,de.lproj). Ensure each target language folder and.stringsfile exists.
cd path/to/your/projectExample:
cd Desktop/MyProjectpython translate_strings.pyOr, if Python 3 is default:
python3 translate_strings.py🌍 Translating 120 keys to 'fr'...
FR Progress: 100%|████████████████████| 120/120 [00:08<00:00, 14.83it/s]
🎉 fr: Translation file written to: ./MyApp/Resources/Localization/fr.lproj/Localizable.strings
- Ensure your base
.stringsfile is correctly formatted before running. - Translations are powered by Google Translate; review results before release.
- You can extend this script to include custom APIs or additional file types.
- Ensure you have an active internet connection during translation.
MyApp/
├── Resources/
│ └── Localization/
│ ├── en.lproj/
│ │ └── Localizable.strings
│ ├── fr.lproj/
│ │ └── Localizable.strings
│ ├── es.lproj/
│ │ └── Localizable.strings
│ └── de.lproj/
│ └── Localizable.strings
├── translate_strings.py
└── ...
Pull requests are welcome! Open an issue on GitHub for bugs or improvements.
This project is licensed under the MIT License — free to use, modify, and distribute with attribution.
- Muhammad Haroon
- Email: [email protected]
- LinkedIn: https://www.linkedin.com/in/mian-haroon