11-17-2010 10:39 AM
Solved! Go to Solution.
11-17-2010 12:36 PM
Not 100% clear on what you are asking, but the following code when invoked will change the default language to French:
Locale.setDefault(Locale.get(Locale.LOCALE_fr, null));
If this does not help, can you please clarify what you would like to be able to do..
11-17-2010 11:49 PM
Thanks for your reply peter,
Actually i need to change my application default language programatically if i select french language means it will need to change the application label,textbox and every thing in the application to french.
Is this possible? Got my point?
Thanks,
Packiaraj M
11-18-2010 04:09 AM
The following code should show you how this can be done. This was a test program I created to test how the DateTime field would look in various languages. Not production code.....
import net.rim.device.api.i18n.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.io.http.HttpDateParser;
public class LanguageTestScreen extends MainScreen
implements FieldChangeListener {
static String [] LANGUAGES = new String [] { "English", "French", "Spanish" };
ObjectChoiceField _languageChoice = new ObjectChoiceField("Select Language:", LANGUAGES);
DateField _testDateField = null;
DateField _testDateField2 = null;
private SimpleDateFormat sdFormatDate = new SimpleDateFormat("EEE dd MMM yyyy");
private long _dateToDisplay = HttpDateParser.parse("2010-04-17");
public LanguageTestScreen() {
super();
this.add(_languageChoice);;
_languageChoice.setSelectedIndex(0);
fieldChanged(_languageChoice, 0);
_languageChoice.setChangeListener(this);
}
public void fieldChanged(Field f, int context) {
int langIndex = _languageChoice.getSelectedIndex();
if ( langIndex == 0 ) {
Locale.setDefault(Locale.get(Locale.LOCALE_en, null));
} else
if ( langIndex == 1 ) {
Locale.setDefault(Locale.get(Locale.LOCALE_fr, null));
} else {
Locale.setDefault(Locale.get(Locale.LOCALE_es, null));
}
if ( _testDateField != null ) {
this.delete(_testDateField);
this.delete(_testDateField2);
}
sdFormatDate = new SimpleDateFormat("EEE dd MMM yyyy");
_testDateField = new DateField("Test1: ", _dateToDisplay, sdFormatDate);
this.add(_testDateField);
_testDateField2 = new DateField("Test2: ", _dateToDisplay, DateField.DATE);
this.add(_testDateField2);
}
}
11-18-2010 08:29 AM
Thanks for your help peter..
if i need to install that particular language?
i have tried your code in storm2 simulator its not change the language....
11-18-2010 11:32 AM
You should test my code on a Simulator. I think most simulators have French and Spanish installed.
You install/remove languages as part of the Device OS. The easiest way I find is to connect your Storm 2 to a Desktop Manager, and go through the process to update the OS. You should see the languages that you add in there.
11-18-2010 11:41 PM
Ok fine thanks peter.. but if my user dont have these language in real device means.... how can i install automatically when my application launch, do u have any idea..?
11-19-2010 04:57 AM - edited 11-19-2010 04:58 AM
I am not aware of any way your application would be able to add language support to the device. If the language is not there, I think the best you can do is tell the user.
11-19-2010 11:53 PM
Ok thanks peter, i have another question in video streaming.. can you please look at this thread and please help me...
http://supportforums.blackberry.com/t5/Java-Develo
Thanks,
Packiaraj M
11-20-2010 08:11 AM
Sorry, video streaming is not an area of expertise. Can you mark this as solved?.