Alternate Resources Localization

Alternate Resources and Localization is a very useful issue you will love Android for. Expect you would have to design a GUI that fits landscape and portrait screen-orientation well at the same time - that is almost impossible.

You can supply different resources for your application according to the UI language or hardware configuration of the device. Note that eventhough you can include different string, layout, and all other resources, the SDK does not expose methods to let you specify which alternate resource set to be used. Android detects the proper set for the hardware and location, and loads them as appropriate. Only the user can select alternate language settings using the settings panel on the device.

To include alternate resources, create parallel resource folders with dash-separated qualifiers appended to the folder names, indicating the configuration it applies to (language, screen orientation, dpi, resolution,

For example, here is a project differs between differs between English and German value-resources (here only strings):

MyApp/

res/

values-en/

strings

xml

values-de/

strings

xml

Android supports several types of qualifiers, with various values for each. Append these to the end of the resource folder name, separated by dashes. You can add multiple qualifiers to each folder name, but they must appear in the order they are listed here. For example, a folder containing drawable resources for a fully specified configuration would look like:

MyApp/ res/

drawable-en-rUS-port-92dpi-finger-keyshidden-12key-dpad-4 8 0x32 0/

More typically, you will only specify a few specific configuration options that a resource is defined for. You may drop any of the values from the complete list, as long as the remaining values are still in the same order:

MyApp/

res/

drawable-en-rUS-finger/ drawable-port/ drawable-port-160dpi/ drawable-qwerty/

Android will pick which of the various underlying resource files fits best during runtime, depending on the current device-configuration.

0 0

Post a comment