Wednesday, May 1, 2013

Internationalization (i18n)


import java.util.*;

public class I18NSample {

   static public void main(String[] args) {


      String language = new String("fr");
      String country = new String("FR");
      Locale currentLocale = new Locale(language, country);
      ResourceBundle messages = ResourceBundle.getBundle("MessagesBundle",currentLocale);


      System.out.println(messages.getString("greetings"));
      System.out.println(messages.getString("inquiry"));
      System.out.println(messages.getString("farewell"));

   }

 /*
MessagesBundle_en_US.properties
greetings = Hello.
farewell = Goodbye.
inquiry = How are you?

MessagesBundle_de_DE.properties
greetings = Hallo.
farewell = Tschüß.
inquiry = Wie geht's?

MessagesBundle_fr_FR.properties
greetings = Bonjour.
farewell = Au revoir.
inquiry = Comment allez-vous?
 */
 
}


No comments:

Post a Comment