App Localization code snippet

Tai Tran
2 min readMar 12, 2020

--

Today’s global world, mobile app localization has become must. Implementing well, it has helped your apps improve the app store ranking, increase download up to 100%, and enhance revenue by almost 50% by using Google Translate API

Below , This code snippet will help your app development more easily using Python language.

  1. Assume that you already had google service json file. You can get it by enable Cloud Translation API and download the google-services.json file.
Cloud Translation API

2. You should exported ‘google-services.json’ path as system variable by this code. In my case, it is the current workspace so it should be :

os.environ[‘GOOGLE_APPLICATION_CREDENTIALS’] = ‘google-services.json

Install google cloud translate package by using pip

pip install google-cloud-translate==2.0.0

3. In my sample, the initial resource language is English, I named it as en.json. Then, you put your translated language code by overwrite the supportLanguage variable.

4. After finishing the set up, right-click and select Run Python File in the terminal.

Take a coffee and get the result in translated folder

Full code here .

--

--

Tai Tran

Mobile, Postgres, DevOps,… Programming enthusiast