The Android resource system provides resources based on your phone's configuration. In this video, learn about a few different resource qualifiers, and see how this topic ties into localization.
- [Narrator] Another component for understanding how localization works, is Android's resource resolution system. Android's flexible, robust, resource system allows resources to be provided at run time to your application, based on the configuration of your activity. You may already be familiar with some of these components, but let's just take a look here in Android studio at how all this works. The first resource qualifier you're probably most familiar with is screen density. So in our local news app here, in the emulator, in the main screen, we have a settings icon on the upper right.
Let's look in Android studio and see how this resource is provided. In the code, if we expand the resources directory, go to drawable, then we can see the settings icon, ic settings white. And when you expand that we see there are five different actual assets all with five different density options. And so run time, depending on the density of the device that your app is running on, only one of these images will be provided. The next resource qualifier is for layout orientation.
So let's take a look at the layout file for the photo of the day screen in the app. So if we go to layout and then open activity underscore photo dot xml we can see what the layout looks like. In portrait, the caption for the picture is beneath the picture, but if we switch to landscape using the orientation toggle button at the top of the layout editor, we see that the caption moves to the right of the picture. And this is also done with a resource qualifier.
In the layout directory, if we expand activity photo dot xml, we see that there are actually two layouts, one default layout and one with the land qualifier or landscape. Now this course is about localization after all, so let's talk about strings. Strings are also provided, based on this exact same resource qualifier system. This app ships six different sets of strings. We can see them if we expand the values directory and then strings dot xml.
This app ships six different sets of strings. One is the default, which happens to be English. And others for German, English spoken in the UK, Spanish, etc. All with their countries flags next to them to distinguish them easily. Exactly how a string is selected from your resources at run time depends on your users language preferences and the availability of the strings, which we'll talk about more in the next video.
- The localization process
- Basic internationalization
- Choosing target markets
- Preparing your app for internationalization
- Translating your app
- Testing and releasing your translated app