Tutorials J2ME Localization in LWUIT

Localization in LWUIT

Localization is built in – You can install a “resource bundle” (Hashtable in LWUIT, ME has no resource bundles), into the PLAF and most of the components (buttons, labels, check boxes etc…) will be automatically localized.

Using Resource editor you can enter the key,value pairs of all string used in the application and different locale and select or load on at run-time to be used in the app.

try
{
// where string.res in your resource 
// file which as locale as language resource in it.
Resources res = Resources.open(MIDlet.class.getResourceAsStream("/strings.res")); 
//Dynamic resource initialized into a locale hash table
locale = res.getL10N("locale","name of needed language locale matching to value column in res file" );
}
catch(Exception e)
{
System.out.println("Exception in loading resource from jar");
}

/// using locale based string
String welcome = (String) locale.get("key.welcome");
g.drawString(welcome);
textArea.setText(welcome);
Total
0
Shares
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Anonymous
Anonymous
12 years ago

What is locale?

javatechig
javatechig
10 years ago
Reply to  Anonymous

A locale is the part of a user’s environment that brings together information which is specific to a user’s particular country, language, or territory.

For more information, visit the following links:

http://www.roseindia.net/java/javadate/locale-format.shtml
http://www.roseindia.net/tutorial/java/corejava/javatext/parseAndFormatDateUsingLocale.html

Thanks

Previous Post
j2me_tutorials_javatechig_featured_image

Capturing RGB Color of pixel

Next Post
j2me_tutorials_javatechig_featured_image

How to Send MMS from J2ME

Related Posts
By clicking “Allow All”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. Cookie Notice
Allow All