concept localization in category android

appears as: localization
Android in Action, Third Edition

This is an excerpt from Manning's book Android in Action, Third Edition.

Table 12.2. Resource files used in the sample application

Filename

Description

android.jpg Image used in the Splash Activity.
icon.jpg Image used in the application launcher.
fieldservice.xml Layout for the main application screen, FieldService Activity.
managejobs.xml Layout for the list of jobs, ManageJobs Activity.
refreshjobs.xml Layout for the screen shown when refreshing the job list, RefreshJobs Activity.
showjob.xml Layout for the job detail screen, ShowJob Activity.
showsettings.xml Layout for the configuration/settings screen, ShowSettings Activity.
splash.xml Layout for the splash screen, Splash Activity.
strings.xml Strings file containing extracted strings. Ideally, all text is contained in a strings file for ease of localization. This application’s file contains only the application title.

Many of the strings your application uses can be referenced in the application’s layout files, but there’s often a need for building a string dynamically at runtime to display to the user. These strings embedded into your code must be localized as well! In fact, our experience shows that it’s these strings that flesh out the application and test your discipline as a developer committed to localization. These are also the strings that send you back to the translation team with further requests for translation services!

The first and fundamental use of localized strings in code is the simple string retrieved from the string table and directly displayed without further formatting. We’ll start by looking at a snippet of the Field Service application’s code prior to localization. The following listing shows the onCreateOptionsMenu() method, which handles the creation of the presented menu options.

Listing 18.4. Menu creation code prior to localization

Even if your application isn’t designed to generate sales revenue directly, its purpose may be to help build your brand and expand your influence. If you’re part of an organization with a presence beyond your home country, localization is important to you as well.