Program to demonstrate how do I use locales and resource bundles to internationalize my application
Properties file :
Output of the program :
package com.hubberspot.example;
import java.util.Locale;
import java.util.ResourceBundle;
public class Properties {
public static void main(String[] args) {
// Create a ResourceBundle by calling getBundle()
// method and passing two parameters, properties file and
// Locale to which we want to internationalize
ResourceBundle resource_en_US = ResourceBundle.
getBundle("Bundle", new Locale("en","US"));
// calling getString() and passing the string we want to get
System.out.println("Message in " + Locale.US + " : " +
resource_en_US.getString("welcome"));
ResourceBundle resource_pt_BR = ResourceBundle.
getBundle("Bundle", new Locale("pt","BR"));
System.out.println("Message in " + new Locale("pt","BR")+ " : " +
resource_pt_BR.getString("welcome"));
}
}
Properties file :
Output of the program :

