What is internationalisation? How can you achieve in java?

Showing Answers 1 - 1 of 1 Answers

sarala

  • Oct 20th, 2005
 

Internationalization is the process of designing an application so that it can be adapted to various languages and regions without engineering changes. Sometimes the term internationalization is abbreviated as i18n, because there are 18 letters between the first "i" and the last "n."

Example:

Example.java

import java.util.*;public class I18NSample {    static public void main(String[] args) {        String language;        String country;        if (args.length != 2) {            language = new String("en");            country = new String("US");        } else {            language = new String(args[0]);            country = new String(args[1]);        }        Locale currentLocale;        ResourceBundle messages;        currentLocale = new Locale(language, country);        messages = ResourceBundle.getBundle("MessagesBundle",                                           currentLocale);        System.out.println(messages.getString("greetings"));        System.out.println(messages.getString("inquiry"));        System.out.println(messages.getString("farewell"));    }}
A properties file is in plain-text format. You can create the file with just about any text editor. 
MessagesBundle.properties
greetings = Hello.farewell = Goodbye.inquiry = How are you?
 
MessagesBundle_de_DE.properties
 
greetings = Hallo.farewell = Tsch??.inquiry = Wie geht's?
 
MessagesBundle_en_US.properties
 
greetings = Hello.farewell = Goodbye.inquiry = How are you?
 
MessagesBundle_fr_FR.properties
 
greetings = Bonjour.farewell = Au revoir.inquiry = Comment allez-vous?
 
Running the program
 
% Example fr FRBonjour.Comment allez-vous?Au revoir.
 
% Example en USHello.How are you?Goodbye.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions