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
packiaraj
Posts: 231
Registered: ‎07-09-2009
My Device: Not Specified
Accepted Solution

Change default language in 4.6

Hi to all, I am currently working in JDE 4.6 . In my application, I need to apply the language localization facility with the languages, such as Spanish, French and Portuguese. I am currently developing in English Language. Please anyone help to develop this localization settings to apply in my application as per the user selection. Thanks in advance, Packiaraj M
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Change default language in 4.6

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

Developer
packiaraj
Posts: 231
Registered: ‎07-09-2009
My Device: Not Specified

Re: Change default language in 4.6

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

 

 

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Change default language in 4.6

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);
    }
}

 

 

 

Developer
packiaraj
Posts: 231
Registered: ‎07-09-2009
My Device: Not Specified

Re: Change default language in 4.6

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

 

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Change default language in 4.6

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.

 

 

Developer
packiaraj
Posts: 231
Registered: ‎07-09-2009
My Device: Not Specified

Re: Change default language in 4.6

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

 

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Change default language in 4.6

[ Edited ]

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. 

Developer
packiaraj
Posts: 231
Registered: ‎07-09-2009
My Device: Not Specified

Re: Change default language in 4.6

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-Development/Streaming-Large-video/m-p/644271#M132860

 

Thanks,

Packiaraj M

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Change default language in 4.6

Sorry, video streaming is not an area of expertise. Can you mark this as solved?.