Skip to content

Latest commit

 

History

History
54 lines (34 loc) · 1.59 KB

README.md

File metadata and controls

54 lines (34 loc) · 1.59 KB

Translator script for Android Strings.xml

Android-Strings.xml-Translator is a Python script that uses the Google Cloud Translation API to translate a whole .xml file to the desired language.

Documentation

The ElementTree XML API

argsparse

Google Cloud Translation API

Installation

Use the package manager pip to install the needed libraries.

pip install google-cloud-translate

Setup

This script uses the Google Cloud API, so you will first of all need a google service account Google Cloud. Make a project and go to API & Services > Credentials in the menu. Under create credentials you will heve to make a service account and later add a key in json format in the service account details page.

After you have your json file containing the key you can add the file path to the script.

os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = r"C:\Users\yourmom\Desktop\Python\AndroidTranslate\APIKey.json" 

Usage

Add the String.xml file to the same file as the script. You can run the script in the console.

To see all the supported language codes:

python AndroidStringTranslator.py list-languages

To run the translator:

python AndroidStringTranslator.py translateFile

Another example of usage: #1 (comment)

License

MIT