Run the import command to load all translations into multilocale.com: In this article, I will be going through the step by step process of translating an Android app which supports more than one language. A multi-language app is essential for growing your business targeting an international audience.
Create Android app
Let's create an Android app in case you don't have one ready to be translated. Open Android Studio. From the top menu select File -> New -> New Project. From the available templates click on Basic Activity and then click on the button Next. You can change or leave the settings as they are on the following screen and click on the button Finish. Click on the green arrow button to run your app in the Emulator or a physical device to be sure the app was properly working before we tried translating it.
Multilocale web interface
Signup at https://www.multilocale.com/signup to create an account you can use to visually edit and share translations. The account will also allow you to login in the terminal CLI and in the browser's plugin.
Terminal CLI
We'll be using the terminal or Command Prompt to install a Command Line Interface program called multilocale. The multilocale CLI allows to:
- import all existing strings for an Android app
- Google Translate the strings to many languages
- download back the translated strings into the Android project You will need to have installed node.
Open the terminal and run:
npm install -g multilocale
Run multilocale to see it's installed correctly:
multilocale
Import existing strings
Change you current directory to the root folder of your Android project:
cd some-folder/my-android-project multilocale import
You will be asked to enter the email and password you used to signup at https://www.multilocale.com/signup All you strings from the folder /app/src/main/res/values/strings.xml will be imported and you can view them and edit them at https://app.multilocale.com/projects/app
Download back the translations files
From the Android root folder run the following command to download back all the existing translations files:
multilocale download
Each language will be in a folder named: /values-LANGUAGE. For example the Spanish translations will be in the folder /values-es You can test the new translation files. Change the language from the Settings app of your physical device or emulator. Open back the app and check the strings have been translated.
Add new strings
*You can add new strings and edit existing ones at * https://app.multilocale.com/projects. You can invite other team-mates that work with you on the project. You will need to download back the translation files using the CLI. You can also add strings directly from the CLI by running:
multilocale add 'SOME_KEY' 'SOME_VALUE'
If the key and value of the string are the same you can also just pass the key
multilocale add 'SOME_KEY'
Conclusion
And there we go! We have successfully added multi-language support support to our Android app. We can now translate the app to new languages easily s and find new users in new countries! A multi-language app is usually difficult to build but with Multilocale, we can easily build an app with complex functionalities in a short time. This post is just the tip of the iceberg considering the amount of things that could be done with Multilocale. I hope this article has helped you to understand how a multi-language app can be created with Android. A working example of this project can be found at this github repo Thanks for reading!