Let’s guide you through the steps to show you how to create a multilingual Android app with Android Studio. Localizing your Android app may boost sales, increase conversion rate and improve the overall user experience.
Android Studio is the official Android IDE developed by Google.
If this is your first Android Studio project: simply install Android Studio, create a new project from the “Blank Activity” template and drag some UI widgets to the blank canvas space.
We used this little example view (to the right) that we will be using for this post.
By default, UI widgets store their label in hard-coded strings. If you hover your cursor over a UI widget, Android Studio will show a tooltip that offers to move this hard-coded string to a resource file named strings.xml.
Go ahead, follow the tooltip and move all your translatable strings to the strings.xml resource file.
Translating With The Android Studio Translation Editor
In your projects file navigator, expand the newly created values directory, right-click the strings.xml file to open the Translation Editor.
In the Translation Editor, click the globe-icon to add a new language file, in our example we will add ‘de’ (German) and ‘es‘(Spanish). We also want to add the region locale ‘de-at‘ for Austria, which can’t be created with the editor. As a result we need to create the directory ‘values-de-rAT‘ in the resources folder and create a strings.xml.
You may need to close and re-open the Translation Editor tab after adding a new language if it does not show up immediately.
You can now start translating your strings. If a string is not translated in a locale, the app will automatically revert to the most similar translation. E.g if a translation is missing in the Austrian localization, it will use the German translation and if it’s missing there, too, the default language will be used – which usually is the english language file.
And voila: you’re done! There is no extra code for language selection needed. Android will select the right locale based on the device language if it is available in your published application.
Getting Professional Translation And Sharing String Files With Translators
If you want to take localization one step further, check out PhraseApp, our service that helps you manage your translation process online. You can even order professional translations with the click of a button.
The PhraseApp Android Studio Plugin integrates seamlessly with Android Studio and the Translation Editor. Install the Plugin, after restarting it should appear at the right toolbar of your IDE.
Next you can let the plugin create your PhraseApp configuration.
Just paste the access token and the plugin will guide you through the steps. After successfully initialisation you can now pull and push your locales.
Customize PhraseApp’s push and pull commands
If you need to customize how to push or pull the locales from PhraseApp you can edit
.phraseapp.yml. For further readings how to edit the configuration take a look at our documentation.
Looking for more information on how you can localize your software, app or website? Download your copy of our free eBook The Complete Guide to Growing Your Business with Localization here and receive tips.
Also published on Medium.