DEV Community

Domenic
Domenic

Posted on

Android Studio strings.xml Parser

Hello all! Today I have a small blurb about a relatively basic, yet helpful tool I have recently created and used. The idea of the program is to facilitate generating the strings.xml file so your app can support multiple languages.

Currently, Google offers a $0.07 fee per word if you would like your app to be professionally translated for any language. This may not seem like a lot, but if you have many strings in your resource file and want to support many languages, the price to get your app translated can easily grow into the hundreds. If you are okay with paying that, then by all means. Otherwise, if you are not okay with paying for something Google Translate can do (and want to speed up your efficiency with this progress), checkout my newest GitHub contribution: https://github.com/developer-dmp/Android-Studio-Strings-Parser.

There is some information at the GitHub link about usage, but here is a brief overview of how it works:

Pull the project down to your local machine
Input your strings.xml file at input/strings.xml
Run the program to parse the file
Take content from output/strings_content.txt and paste in Google Translate
* Translate the text to whatever language you want
Take the translated text and paste it in input/strings_content_converted.txt
Run the program again to rebuild the strings.xml file

Boom. Now you have a newly formatted strings.xml file in output/ which you can copy and paste into your strings.xml file in Android Studio for whatever locale you were looking to support.

This process isn't fully automated, but that's because the Google Translate API isn't free -__-

The program I wrote (in Intellij if you were wondering) tremendously increased efficiency in the process of creating numerous strings.xml files for the different locales/languages you want to support. I just used this program for the app I am nearing the release of and was able to go through 35 languages in 20 minutes. My strings.xml file is over 100 lines long too, so I was able to perform thousands of translations and numerous rebuilds of the strings.xml file without ripping my eyes out.

Please let me know if the program was of any use to anyone reading the post, any potential improvements you can think of, and if there is a service out there that is 100 times better than mine and I just wasted my time re-inventing the wheel! xD

Top comments (0)