iwebie
HOME MOVIES TV SHOWS SPORTS GENERAL
 RSSPRIVACY
 

I18N Internationalization
Posted by admin on June 23rd, 2008

Watch over 100,000 movies and TV shows on your PC

I18N – Internationalization

Internationalization is a process of designing a software application so that it can support various languages. All the text messages to be displayed in the application is to be listed in a centralized file and can be accessed depending upon the user preferences later in the JSP file or Java class. The advantage is that the specified labels or descriptions can be reused in multiple JSP files and to provide multiple language support for the application.

Locale is a representation of a language and country combination,eg. en_US,es_SP. The language codes are specified in lowercase and the country codes are specified using uppercase characters, as defined by International Organization for Standardization – the ISO. The country code is optional, so ‘en’ alone can be a valid locale string for the English language.

Common centralized file also known as resource bundles are simply property files with message key and corresponding value pairs,this is to be prepared for every language using the filename convention as MessageResource_en_US (filename_languagecode_country) if country code is used else can be named as MessageResource_en (filename_languagecode) with the file extension “properties”. The messages are placed in the file using the convention as message key followed by the actual text message to be displayed. i.e.greeting=Hello(hi)where the string greeting would be the message key which will be placed in either the JSP or Java class and the word “Hello(hi)” would be displayed on the User Interface. The message key would be the same for all the locales.

Sample Java Class Code

[sourcecode language='java']
import java.util.Locale;
import java.util.ResourceBundle;

public class I18N {

static public void main(String[] args) {

String language;
Locale prefferedLocale;
ResourceBundle messages;

if (args.length != 1) {
language = new String(”en”);
} else {
language = new String(args[0]);
}

prefferedLocale = new Locale(language);
messages = ResourceBundle.getBundle(”MessageResource”, prefferedLocale);
System.out.println(messages.getString(”greeting”));
}
}
[/sourcecode]

Then Create a property file as

MessageResource_en.properties
greeting=hello (hi)

MessageResource_es.properties
greeting=hola! saludo

Compile the java code and provide the argument with the language code to get appropriate language display.

javac I18N.java
java I18N en //To get output in English
or
javac I18N.java
java I18N es //To get the Output in Spanish

Implementation of I18N for a Web based Application would be published shortly.

Bookmark Article
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • StumbleUpon
  • Technorati
  • Propeller

Leave a Reply

Most Popular

Watch over 100,000 movies and TV shows on your PC
Recent Posts

  • Watch Dexter Season 4 Episode 9 | Dexter Hungry Man Online Video
  • Californication Season 3 Episode 9 | Watch Mr. Bad Example Full Episode
  • Watch The Amazing Race Season 15 Episode 9 | The Amazing Race s15e09 Full Video
  • English Premier League | Watch Aston Villa vs Burnley Streaming Live
  • Stargate Universe Season 1 Episode 9 | Watch Stargate Universe s01e09 Life Video Online
  • Smallville Season 9 Episode 9 | Watch Smallville s09e09 Pandora Online Free
  • Monk Season 8 Episode 14 | Watch Mr. Monk and the Badge Streaming Video
  • Community Episode 10 | Watch Community s01e10 Environmental Science Stream Online
  • Watch It’s Always Sunny in Philadelphia Season 5 Episode 10 Full Episode
  • Survivor: Samoa Episode 10 | Watch Survivor s19e10 The Day of Reckoning Free Online
Archives

  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
Powered by WordPress