android localization: Is it a good practice to have only needed resource to put in localized folder?
My application has 4 languages in it. However only one module needs to be localized out of 5,
This module has 4 layout files and some images, remaining files can be there in default layout
folder and drawable
开发者_如何学JAVAfolders.
My question is : is it good practice to put only needed files in localization folders, if I leave other files in its respective folders and don't copy them in translation folders, does my application throw NullPointerException
when my application runs in other language?
and
Does android market have any size limit? (Also being a BB developer,AFAIK they do not allow OTA, if the application size grows more than 3 mb) [In case i need to copy the layout and image files].
Note about NullPointerException
: it throws in string if you omit some string in localization and application runs in that particular locale.
Thanks
Short answer (to your first question): Yes, it is good practice "to put only needed files in localization folders".
You should make sure that every resource you use (that is, every R.something.something
that you refer to) is defined in your default res
directories. Then, for your other languages, you only define the resources that you want to localize.
For the sake of an example, let's say that your default resources are in English, and you want to localize part of your app for Hindi and Gujarati. You should have all your English strings defined in res/values/strings.xml
, the Hindi strings in res/values-hi/strings.xml
(only Hindi, no English!), and the Gujarati strings in res/values-gu/strings.xml
(only Gujarati, no English!)
When the application runs on a device, every reference to a resource (every R.string.some_string_key
) will be checked to find the best match for the locale that device is using. So, if the device is in a Hindi locale, it will pull string values from res/values-hi/strings.xml
, and if it doesn't find them there, it will drop back to the default (English) in res/values/strings.xm
l. It will only throw an exception if can't find the resource in the default /res/values
folder.
精彩评论