Internationalization(I18N) in java

Internationalization(I18N) : The process of designing web applications in such a way that which provides support for various countries, various languages and various currency automatically without performing any change in the application is called Internationalization(I18N). It is know as I18N because between I and N there is 18 characters thats why I18N.

Example: We all know about amazon website, it is world-wide available. We Indians also access the website and any other country person also access the website. If any request is coming from Indian person then the response from the amazon website should be in the form which is understandable by Indian People like Currency should be in INR etc. But at the same time if US people access the website then the response/information given by the website should be in some form which is understandable by US people like here currency should be in $. The above process is known is Internationalization(I18N).

We can implement Internationalization by using the following 3 classes:

  • Locale
  • NumberFormat
  • DateFormat
filter_none

edit
close

play_arrow

link
brightness_4
code

// Java Program to illustrate Program 
// without Internationalization
public class InternationalizationDemo
{
    public static void main(String[] args) 
    {
        System.out.println("Hello");
        System.out.println("Geeks");
        System.out.println("How are you?");
    }
}

chevron_right


Explanation: If we want that this program needs to display these same messages for people living in ITALY and SPAIN. Unfortunately Our programming staff is not multilingual, then we have to translate the above message in ITALY and SPAIN. suppose we dont know languages of ITALY and SPAIN . Then our program will not word for ITALY and SPAIN people. It looks like the program needs to be internationalized.

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java Program to illustrate Program with 
// Internationalization
import java.util.*;
import java.text.*;
class NumberFormatDemo {
    public static void main(String[] args)
    {
        // Here we get the below number
        // representation in various countries
        double d = 123456.789;
        NumberFormat nf = NumberFormat.getInstance(Locale.ITALY);
        NumberFormat nf1 = NumberFormat.getInstance(Locale.US);
        NumberFormat nf2 = NumberFormat.getInstance(Locale.CHINA);
          
        System.out.println("ITALY representation of " +
                            d + " : " + nf.format(d));
                              
        System.out.println("US representation of " +
                            d + " : " + nf1.format(d));
                              
        System.out.println("CHINA representation of "
                            d + " : " + nf2.format(d));
    }
}

chevron_right


output:

ITALY representation of 123456.789 : 123.456, 789
US representation of 123456.789 : 123, 456.789
CHINA representation of 123456.789 : 123, 456.789


My Personal Notes arrow_drop_up

Hello everyone, I am Bishal KUMAR Dubey and most importantly an idea creator I just love Programming languages and love to know new concepts everyday,every minute,every second Here to help Other GEEKS

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.