Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 55
Registered: ‎09-09-2008
My Device: Not Specified
Accepted Solution

How can we localize dynamic data which is coming from server?

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.

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: How can we localize dynamic data which is coming from server?

[ Edited ]

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.]




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
Posts: 55
Registered: ‎09-09-2008
My Device: Not Specified

Re: How can we localize dynamic data which is coming from server?

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. 

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: How can we localize dynamic data which is coming from server?

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.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.