Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7526077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:44:09+00:00 2026-05-30T03:44:09+00:00

I have made a simple form with one textField and command, I want to

  • 0

I have made a simple form with one textField and command, I want to have two languages: Farsi and English so that I can use them according to my needs at runtime.

I made some translations using ResourceEditor and saved them under the name English.res and Farsi.res, then added them to my resources.

Now I have a problem calling Localization method, as I have no idea how to do that. I will post my code here, please correct me.

This is my code:

public class Midlet extends javax.microedition.midlet.MIDlet {

    private Hashtable locale;

    public void startApp() {
        Display.init(this);

        try {
            Resources res = Resources.open("/Lang.res");    
            //Lang.res is resource file where these languages are stored
            // using resoureEditor.
            locale = res.getL10N("English.res", "en");

           /* See text below. */
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        Form main = new Form((String) locale.get("FORM"));
        main.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

        Label label = new Label((String) locale.get("NAME"));
        TextField tf1 = new TextField("");
        Button button = new Button((String) locale.get("OK"));

        main.addComponent(label);
        main.addComponent(tf1);
        main.addComponent(button);

        main.addCommand(new Command((String) locale.get("BACK")) {
            public void actionPerformed(ActionEvent evt) {}
        });
        main.show();
    }
    public void pauseApp() {}
    public void destroyApp(boolean unconditional) {}
}

And this is my English.res:

#Export locale from the Theme Creator
#Tue Aug 02 19:35:55 IRDT 2011
FORM=form
OK=ok
BACK=back
NAME=name

Are these two lines in the try block correct?

       Resources res = Resources.open("/Lang.res");    
       locale = res.getL10N("English.res", "en");

Lang.res is resource file where these languages are stored using resoureEditor.

What else do I need to do?

I get an exception in the first line. en is the name of the needed language locale, matching to the value column in res file.

I’m still not sure if it’s correct or not but, what is this first argument? Locale?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:44:10+00:00Added an answer on May 30, 2026 at 3:44 am

    I suggest using “Resource Editor” for creating L10N resource, it can be synchronized with the gui, making this task easier to do and it’s easire to retrieve in the code.

    try {
            Constants.res = Resources.open("/Lang.res");
        } catch (Exception e){
            System.err.println("can't load resource file:" + e);
        }
    Hashtable h = Constants.res.getL10N("English.res","en");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started using jQuery and rails. I have made a simple form that
Hey all, i have made a simple form that mimiks the jQuery GROWL effect
I have made a simple web form in Google app engine where I have
i have made a simple php contact form following this tutorial: http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme The big
I have made a simple test application for the issue, two winforms each containing
Let's say that I have a file (file1.php) with a simple form with the
I have made a simple web-page including a couple of static pages, a css
I have made my own file type (.ddd) and I made a simple program
So I have made a simple site for a friend using codeigniter and grocery
Just wondering about some practice about this; I have made a simple visual C#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.