mobileDeveloper
mobileDeveloper

Reputation: 894

put the application blackberry multilang (different languages)

I want to make my application Blackberry in different languages. That mean I use english as default language and then when the user select other language, all the items and all the application will be with the other language. I use this code and I put the file Local.rrc and .rrh in the same package. I obtain nothing in my screen just white screen. Can any one help me ?

    package mypackage;

import net.rim.device.api.ui.MenuItem; 
import net.rim.device.api.ui.UiApplication; 
import net.rim.device.api.ui.component.*; 
import net.rim.device.api.ui.container.*; 
import net.rim.device.api.i18n.*; 
public class Local extends UiApplication { 
    public static void main(String[] args) { 
    Local theApp = new Local(); 
    theApp.enterEventDispatcher(); 
     } 
    public Local() { 
      pushScreen(new LocalScreen()); 
     } 
    } 
    final class LocalScreen extends MainScreen implements LocalDemoResource { 
    private static ResourceBundle res = 
     ResourceBundle.getBundle(BUNDLE_ID, BUNDLE_NAME); 
     LabelField title; 
     RichTextField rtf; 
    public LocalScreen() { 
       super(); 
    title =  new LabelField(res.getString(FIELD_TITLE),LabelField.ELLIPSIS| LabelField.USE_ALL_WIDTH); 
      setTitle(title); 
       rtf = new RichTextField(res.getString(MESSAGE)); 
      add(rtf); }


    public void HelloWorldScreen()
    {
     LabelField title = new LabelField("HelloWorld Sample", 
             LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
        setTitle(title);
        add(new RichTextField("Hello World!"));
    }


    public boolean onClose() { 
         Dialog.alert(res.getString(GOODBYE)); 
         System.exit(0); 
        return true; 
        }
    protected void makeMenu(Menu menu, int instance) { 
         menu.add(_english); 
         menu.add(_french); 
         menu.add(_spanish); 
         menu.add(_close); 
        } 
        private MenuItem _close = new MenuItem(res.getString(CLOSE), 110, 10) { 
        public void run() { 
          onClose(); 
         } 
        }; 
        private MenuItem _english = new MenuItem(res.getString(ENGLISH), 110, 10) 
        { 
        public void run() { 
        Locale.setDefault (Locale.get(Locale.LOCALE_en, null)); 
          refresh(); 
        } 
        }; 
        private MenuItem _french = new MenuItem(res.getString(FRENCH), 110, 10) { 
        public void run() { 
        Locale.setDefault (Locale.get(Locale.LOCALE_fr, null)); 
          refresh(); 
          } 
        }; 
        private MenuItem _spanish = new MenuItem(res.getString(SPANISH), 110, 10) 
        { 
        public void run() { 
        Locale.setDefault (Locale.get(Locale.LOCALE_es, null)); 
          refresh(); 
         } 
        };
        private void refresh() { 
            title.setText(res.getString(FIELD_TITLE)); 
             deleteAll(); 
            rtf = new RichTextField(res.getString(MESSAGE)); 
             add(rtf); 
            _english.setText(res.getString(ENGLISH)); 
            _french.setText(res.getString(FRENCH)); 
            _spanish.setText(res.getString(SPANISH)); 
            _close.setText(res.getString(CLOSE)); 
            } 
    }

Upvotes: 0

Views: 404

Answers (1)

mobileDeveloper
mobileDeveloper

Reputation: 894

There is an example import--->import blackberry samples---->LocalizationDemo explain how to use multilang in application blackberry

Upvotes: 1

Related Questions