Open In App

Internationalization(I18N) in Java

Last Updated : 17 Dec, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

Internationalization(I18N) is the process of designing web applications in such a way that which provides support for various countries, various languages, and various currencies automatically without performing any change in the application is called Internationalization(I18N). It is known as I18N because between I and N; there are 18 characters; that’s why I18N.

Internationalization is one of the powerful concepts of java if you are developing an application and want to display messages, currencies, dates, time, etc., according to the specific region or language.

Example: We all know about the Amazon website. It is worldwide available. We Indians also access the website, and any other country person also accesses the website. If any request is coming from an Indian person, then the response from the amazon website should be in the form 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 as Internationalization(I18N).

We can implement Internationalization by using the following three classes: 

Java




// 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?");
    }
}


Output

Hello
Geeks
How are you?

Explanation: If we want this program to display these same messages for people living in ITALY and SPAIN. Unfortunately, Our programming staff is not multilingual, and then we have to translate the above message in ITALY and SPAIN. Suppose we don’t know the 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.

Java




// Java Program to illustrate Program with
// Internationalization
  
import java.text.*;
import java.util.*;
  
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));
    }
}


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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads