List of usage examples for java.util Locale getLanguage
public String getLanguage()
From source file:Main.java
public static void main(String[] args) { Locale locale = new Locale("en", "US", "WIN"); System.out.println("Locale:" + locale); // get language and print it System.out.println("Language:" + locale.getLanguage()); }
From source file:modelibra.swing.app.config.NatLang.java
public static void main(String[] args) { Log4jConfigurator log4jConfigurator = new Log4jConfigurator(); log4jConfigurator.configure();/*from w w w . j a va 2 s . co m*/ NatLang lang = new NatLang(); lang.setNaturalLanguage("en"); Locale locale = lang.getLocale(); log.info("--- Language ---"); log.info("Country: " + locale.getCountry()); log.info("Language: " + locale.getLanguage()); String text = lang.getText("selectDirectory"); log.info("Selected text: " + text); }
From source file:Main.java
public static void printLocaleDetails(Locale locale) { String languageCode = locale.getLanguage(); String languageName = locale.getDisplayLanguage(); String countryCode = locale.getCountry(); String countryName = locale.getDisplayCountry(); // Print the locale info System.out.println("Language: " + languageName + "(" + languageCode + "); " + "Country: " + countryName + "(" + countryCode + ")"); }
From source file:Main.java
public static String getLanguage() { Locale locale = Locale.getDefault(); return locale.getLanguage(); }
From source file:Main.java
/** * Get locale pairs. /*from ww w. j a v a2s . c o m*/ * @param source * @param target * @return In the pattern like, "ENUS-DEDE" */ public static String getLocalePairs(Locale source, Locale target) { String part1 = source.getLanguage() + source.getCountry(); String part2 = target.getLanguage() + target.getCountry(); return part1 + "-" + part2; }
From source file:Main.java
public static String getLocaleLanguage() { Locale l = Locale.getDefault(); return String.format("%s-%s", l.getLanguage(), l.getCountry()); }
From source file:Main.java
private static String getLocale() { final Locale locale = Locale.getDefault(); return locale.getLanguage() + "-" + locale.getCountry().toLowerCase(); }
From source file:Main.java
/** * @return the string for the given locale, translating * Android deprecated language codes into the modern ones * used by Chromium./* w ww .j av a2 s .c o m*/ */ public static String getLocale(Locale locale) { String language = locale.getLanguage(); String country = locale.getCountry(); // Android uses deprecated lanuages codes for Hebrew and Indonesian but Chromium uses the // updated codes. Also, Android uses "tl" while Chromium uses "fil" for Tagalog/Filipino. // So apply a mapping. // See http://developer.android.com/reference/java/util/Locale.html if ("iw".equals(language)) { language = "he"; } else if ("in".equals(language)) { language = "id"; } else if ("tl".equals(language)) { language = "fil"; } return country.isEmpty() ? language : language + "-" + country; }
From source file:Main.java
public static String getLanguageEnv() { Locale l = Locale.getDefault(); String language = l.getLanguage(); String country = l.getCountry().toLowerCase(); if ("zh".equalsIgnoreCase(language)) { if ("cn".equals(country)) { language = "zh-CN"; } else if ("tw".equals(country)) { language = "zh-TW"; }//ww w . j a v a 2 s . co m } return language; }
From source file:Main.java
public static String getLanguageCode(Locale locale) { String languageCode = locale.getLanguage(); if (!locale.getCountry().isEmpty()) { languageCode += "-" + locale.getCountry(); }//from w ww . j av a 2s . com return languageCode; }