Free Data Structures and Algorithms Course









Subscribe below and get all best seller courses for free !!!










OR



Subscribe to all free courses

How do I use locales and resource bundles to internationalize my application?

Program to demonstrate how do I use locales and resource bundles to internationalize my application

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 : 





 
© 2021 Learn Java by Examples Template by Hubberspot