Android Localization: Getting Started

Android runs on many devices in many regions. To reach the most users, your app should handle content to reflect the locales where your app is used. By Jemma Slater.

Leave a rating/review
Download materials
Save for later
Share
You are currently viewing page 4 of 4 of this article. Click here to view the first page.

Drawables

You’ve already covered a lot in this tutorial, but there’s still one thing left to address. The app still shows the US flag to users of all locales!

By now, you’ve probably got the hang of adding resource files for different configurations, but here are the steps one more time.

Create a new resource directory where you’ll add a new image to display to British users. As before, right click on the res package and select New ▸ Android resource directory. You need to create a new drawable folder for the en-GB locale. Select drawable as the resource type, locale as the qualifier, en:English as the language and GB:United Kingdom as the region.

When you add a new image to this directory, you’ll need to make sure to save it with the same name as the default image. That way, when the device switches locale it can use the same filename referenced in the code to get the image.

For the sample app, you should save the new image with the filename img_flag.png. You can either save this image directly into the folder using a File Explorer on your machine, or drag and drop the image file into the folder in Android Studio.

Feel free to find your own image to use here. But here’s a cute little Union Jack in the same style as the existing US flag you can use. Right click and save it into your new GB resource directory.

You’ve now added a localized drawable. Build and run the app again. Change your emulator or device’s primary language to English (United Kingdom) and open the app again to see the new image displayed on the screen.

Localization Checklist

Google provides much of support for developers through the Google Play store. For localization, they’ve provided a handy Localization Checklist to help get your app ready to support new locales.

The checklist contains useful tips to ensure you haven’t forgotten anything and covers the whole process from start to finish. It’s a very useful resource and worth checking out both before and after you decide to target multiple locales.

If you’ve covered everything in that checklist, you should be ready to go!

Where to Go From Here?

Download the final project using the Download Materials button at the top or bottom of this tutorial.

As you’ve seen, there are many things to consider when localizing your apps to target different audiences. But Android makes it fairly simple to add all these different configurations to your project through resource directories.

If you want to try increasing localization support further in your apps, look at providing alternative resources for other aspects of your app, such as custom layouts, multiple currencies or audio files. As a starting point for adding audio files, read the documentation on MediaPlayer.

The skills you have gained in this tutorial for making new resource files with qualifying identifiers can help you make your app more robust in other areas, too. Try playing around with providing other qualifiers for resource files, such as screen orientation or size. You’ll find a list of all available qualifiers here.

Hopefully, this tutorial covered enough to get you started on the road to supporting as many users as possible in ways that appeal to them. If you have any comments or questions, use the forum below.