This script has been superseded by AutoLocalizer, a free GUI that translates your strings locally using an open Large Language Model rather than ChatGPT. Not only does this require less effort, it's also more private as your data doesn't leave your Mac at all. This script will still continue to work for the foreseeable future if you prefer to use ChatGPT.
- Open your Localizable.xcstrings file with a text editor and copy it into data.json.
- The ChatGPT API costs money and isn't really necessary here, so instead, use extract.py to extract all strings from your project and translate them with ChatGPT. Example prompt:
"Please help me translate all these sentences into german:"
- Copy the output into the sentence_str variable in merge.py
- Specify your language_key in merge.py
- Run merge.py. This will update your data.json file.
- Open your Localizable.xcstrings file with a text editor and replace its contents with the output of merge.py (which you will find in data.json)
To add more languages, repeat steps 2-5, and then finish off with 6.
Pull requests are welcome. I did all this in like 30min so there are almost certainly edge cases I haven't thought of.