Java I18N – Display Language


Java Internationalization – Locale Language


”;


Example

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

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

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *