[Automate] Google Translate Python Script for App Localization
The Case for Localization
The greatest thing about creating software and distributing it via the internet, is the global reach you instantly get. Users across all of my apps (✍️Writeaday 👇Taskaday) skew towards the United States, but there are plenty of users in other countries as well that I need to support. 21% of my Writeaday users are from the US, which means that 79% are not.
Manual Copy & Paste
Most app developers are familiar with the pain of translating their app into other languages. While Google has built Android to accommodate many languages, it’s still on the app developers themselves to translate all strings that are used in their apps.
In order to get basic translations out to users, what I’ve been doing for the past 3 years is to manually go into Google Translate and translate each string, copy and paste it into my project, and then repeat for the hundreds of strings.
Time to Scale
I finally got around to writing a script to automate all of this. By parsing the string with Python and then using a python library called google-trans-new, I was able to build a script to translate all of my apps’ strings.
I still have some work to do, but in the next hour or so, my script should be able to generate strings.xml
files for every translated language, for all of my apps.
My script can actually create the actual translated <string name=””></string>
directly into my strings.xml files now!
Still Running…
I hit the max limit for the Google Translate API, switched to a VPN, and now I’m at roughly 4 hours of running this script. About 40 languages have been translated so far:
2 hours later…
Reviews
The reviews for ✍️ Writeaday have clearly called out how some languages are not translated or are translated incorrectly. With this script, I can at least provide a basic translation of all languages.
From there, my plan is to offer users a feature where they can suggest a better translation directly within the app. If this proves too hard to build, I may have to transition to a paid option like Localazy.
Resources
I later found out about some of these resources that you can use to translate your app strings or to help you build a better script: