Java Internalization - Locale Language


Advertisements

In this example, we'll get display language per locale passed as an argument.

I18NTester.java

import java.util.Locale;

public class I18NTester {
   public static void main(String[] args) {
      Locale defaultLocale = Locale.getDefault();
      Locale enLocale = new Locale("en", "US");  
      Locale frLocale = new Locale("fr", "FR");  
      Locale esLocale = new Locale("es", "ES");

      System.out.println(defaultLocale.getDisplayLanguage(enLocale));
      System.out.println(defaultLocale.getDisplayLanguage(frLocale));
      System.out.println(defaultLocale.getDisplayLanguage(esLocale));
   }
}

Output

It will print the following result.

English
anglais
inglés
Print

Useful Video Courses


Video

Java Date and Time Online Training

16 Lectures 2 hours

Malhar Lathkar

Video

Java Servlet Online Training

19 Lectures 5 hours

Malhar Lathkar

Video

JavaScript Online Training

25 Lectures 2.5 hours

Anadi Sharma

Video

Java Online Training

Most Popular

126 Lectures 7 hours

Tushar Kale

Video

Java Essential Training

119 Lectures 17.5 hours

Monica Mittal

Video

Java Essentials Online Training

76 Lectures 7 hours

Arnab Chakraborty

Advertisements