04-22-2010 11:19 AM
I have searched forum but did not get the answer.
For local data we can put in rrh file, what about the text that is coming from server....how to localize this kind of data?
Any idea? Thanks.
Solved! Go to Solution.
04-22-2010 11:33 AM - edited 04-22-2010 11:36 AM
You need to do it on the server side. Obviously, the server protocol needs to support this in some manner.
You can use Locale.getDefault() to get the application's default locale, from which you can extract the language, country, and variant codes.
[Edit: Well, you don't absolutely need to do it that way. The server could, for instance, supply a response that includes all supported localizations. You could then select which one to use on the device. But that wouldn't be my first choice of how to do it.]
04-22-2010 11:46 AM
This helps, thanks Ted_Hopp.
What I am thinking is if server send all the localizations to client, it will cost customer more money to download the data, right? so if client send locale information and let server send the exact localization back, that will save some data cost.
04-22-2010 01:39 PM
Glad to help. There's another approach, which I should have thought of earlier, since I've used it. If the strings (or other data) to be localized are fixed in advance, the server can simply respond with a code. The device software can then use that to retrieve the associated resource from the (localized) bundle. The trick is that you have to map server response codes to resource identifiers. This can be done with a static Hashtable, array, or other mechanism of choice.