2

I am designing an application in J2me, where I just have to give interface in a Particular language, say Urdu. What I am doing is using Unicode characters to print labels, like "Welcome" into my language, and its displaying the right way. As this application is supposed to run on different mobile models, I just want to know that if it's programmatic-ally possible to check that if a particular mobile running my application does support unicode of my language? because if it doesn't then it shall show labels in default English language. I didn't code it yet except the conversion of English Alphabets to my language characters, I just want to know and if possible to find a way to perform this check. Thanks in advance :)

Saqib
  • 1,120
  • 5
  • 22
  • 40

1 Answers1

1

There is a System property where you can read the current language selected on the handset.

String locale = System.getProperty("microedition.locale");

The first two letters identify the language while the last two letters identify the country. For example, "en-US" represents English on United States of America, while "pt-BR" represents Portuguese on Brazil.
A good thing is to have all your GUI Strings loaded based on the current language. Lets say you store all those Strings in a single array and initialize it like this:

String messages [] = null;

if (locale.startsWith("pt")) {
    messages = new String [] {
        "Novo Jogo",
        "Configurações",
        "Ajuda"
    };
} else { // default language is English
    messages = new String [] {
        "New Game",
        "Settings",
        "Help"
    };
}

Then you define some constants to identify each index.

static final int MSG_NEW_GAME = 0;
static final int MSG_SETTINGS = 1;
static final int MSG_HELP = 2;

And use them like this (where menuList is an instance of List):

menuList.append(messages[MSG_NEW_GAME], null);
menuList.append(messages[MSG_SETTINGS], null);
menuList.append(messages[MSG_HELPS], null);

With this you have support for two languages in your application. The more cases you have for messages initiation based on locale, the better for your end user.

As seen at http://smallandadaptive.blogspot.com.br/2008/12/internationalization-or-just-i18n-count.html

Telmo Pimentel Mota
  • 4,033
  • 16
  • 22
  • I have nothing to do with the language selected by the handset, I have used that property but that doesn't help, what I want to do is whether that handset supports unicode or not for the specific language I am converting to. Thanks – Saqib Oct 07 '12 at 08:05