Android users hail from many different parts of the world. They speak different languages, use different currencies, and format their dates in different ways—just to name a few examples.Android application internationalization generally falls into three categories:
We already discussed how to use alternate resources, but perhaps another example is in order—let’s look at an application that loads resources based upon the device language settings. Specifically, let’s consider a simple application that loads different string and graphic resources based upon the language and region settings of the device.
Internationalization Using Alternative Resources
Let’s look at two examples of how to use alternative resources—this time, to localize an application for a variety of different languages and locales. By language, we mean the linguistic variety such as English, French, Spanish, German, Japanese, and so on. By locale, we are getting more specific, such as English (United States) versus English (United Kingdom) or English (Australia).There are times when you can get away with just providing language resources (English is English is English, right?) and times when this just won’t fly.
Our first example is theoretical. If you want your application to support both English and French strings (in addition to the default strings), you can simply create two additional resource directories called /res/values-en (for the English strings.xml) and /res/values-fr (for the French strings.xml).Within the strings.xml files, the resource names are the same. For example, the /res/values-en/strings.xml file could look like this:<?xml version="1.0" encoding="utf-8"?>
A default layout file in the /res/layout directory that displays the string refers to the string by the variable name @string/hello, without regard to which language or directory the string resource is in. The Android operating system determines which version of the string (French, English, or default) to load at runtime. A layout with a TextView control to display the string might look like this:<?xml version="1.0" encoding="utf-8"?>
It’s as easy as that. So, we move on to a more complex example, which illustrates how you can organize alternative application resources in order to provide functionality based upon the device language and locale.
Again, this application has no real code to speak of. Instead, all interesting functionality depends upon the judicious and clever use of resource folder qualifiers to specify resources to load. These resources are
In this way, the application loads different resources based upon the language and locale information, as shown in Figure. This figure shows the project layout, in terms of resources, as well as what the screen might look like when the device settings are set to different languages and locales.
Changing the Language Settings
Generally, a device ships in a default language. In the United States, this language is English (United States). Users who purchase devices in France, however, are likely to have a default language setting of French (France), while those in Britain and many British territories would likely have the language set to English (United Kingdom)—that said, Australia and New Zealand have their very own English settings and Canada has both an English (Canada) option and a French (Canada) language option.
Using alternative resources for different language string resources.
To change the locale setting on the emulator or the device, you need to perform the following steps:
Make sure you memorize the steps (and related icons, such as the Settings icon) required to change the language settings, as you need to navigate back to this screen in that foreign language, in order to change the settings back.
Changing device language settings.
The Settings icon in English and French (left) and the Settings menu in French (right).
Internationalization forces design choices on the development team. For example, will you build one big project for all languages, or will you break the applications up by region? For some projects with light internationalization, you might be able to get away with one project with all internationalized resources. For deep internationalization, you might need to reorganize projects so that no application becomes too large or cumbersome for the user.
Because much of the work for application localization revolves around alternative resources, this means that this work might fall not to a developer who knows how to use Eclipse and the Android tools well, but to a designer who needs some training on how Android internationalization works, how resources can be layered, and the drawbacks of over-internationalizing (resulting in very large package files with many graphics and such). On the plus side, this leaves developers free to do what they do best: developing code.
Finally, you’ve likely noticed that the Android alternative resource structure isn’t perfect—especially for countries with multiple official (and unofficial) languages. It is possible to work around these issues, when necessary, by loading graphics programmatically based upon the current locale setting on the device, but this should only be attempted when absolutely necessary.
Implementing Locale Support Programmatically
There are times in which you should ensure that your application code is “locale-aware.” Often, this means writing code that is flexible enough to run smoothly regardless of the locale. However, when your application needs to be locale-aware—for example, to download appropriate content from a remote application server—you should rely upon localefriendly methods.
Here are some pointers for developing applications that work in a variety of locales:
Setting Up Your Android Development Environment
Writing Your First Android Application
Understanding The Anatomy Of An Android Application
Defining Your Application Using The Android Manifest File
Managing Application Resources
Exploring User Interface Screen Elements
Designing User Interfaces With Layouts
Drawing And Working With Animation
Using Android Data And Storage Apis
Sharing Data Between Applications With Content Providers
Using Android Networking Apis
Using Android Web Apis
Using Location-based Services (lbs) Apis
Using Android Multimedia Apis
Using Android Telephony Apis
Using Android 3d Graphics With Opengl Es
Using The Android Ndk
Using Android’s Optional Hardware Apis
Working With Notifications
Working With Services
Extending Android Application Reach
Managing User Accounts And Synchronizing User Data
Handling Advanced User Input
Targeting Different Device Configurations And Languages
The Mobile Software Development Process
Designing And Developing Bulletproof Android Applications
Testing Android Applications
Selling Your Android Application
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.