List of usage examples for java.util Locale getLanguage
public String getLanguage()
From source file:Main.java
public static boolean isLocalCN(Context context) { Locale locale = context.getResources().getConfiguration().locale; String language = locale.getLanguage(); return language.equals("zh"); }
From source file:Main.java
public static boolean isZh(Context context) { Locale locale = context.getResources().getConfiguration().locale; String language = locale.getLanguage(); return language.endsWith("zh"); }
From source file:Main.java
public static int getLanguageValue() { int lang = 0; Locale l = Locale.getDefault(); String language = l.getLanguage(); String country = l.getCountry().toLowerCase(); if ("zh".equalsIgnoreCase(language)) { if ("cn".equals(country)) { lang = 1;//w ww . java2s .c om } else if ("tw".equals(country)) { lang = 3; } } else { lang = 2; } return lang; }
From source file:Main.java
public static int getLocalLauguage(Context context) { int code = 0; Locale local = context.getResources().getConfiguration().locale; String s = local.getLanguage(); if (s.equals("en")) { code = 2;//from w w w . j a v a2s .c om } else if (s.equals("zh")) { code = 1; } return code; }
From source file:Main.java
public static boolean isZh(Context context) { Locale locale = context.getResources().getConfiguration().locale; String language = locale.getLanguage(); if (language.startsWith("zh")) return true; else//from w w w . ja v a 2 s . c o m return false; }
From source file:Main.java
public static boolean isZh(Context context) { Locale locale = context.getResources().getConfiguration().locale; String language = locale.getLanguage(); if (language.endsWith("zh")) return true; else/*from ww w. java 2 s .com*/ return false; }
From source file:Main.java
public static boolean isEN(Context context) { Locale locale = context.getResources().getConfiguration().locale; String language = locale.getLanguage(); if (language.endsWith("en")) { return true; }/*from w w w. j a v a2s. c o m*/ return false; }
From source file:com.enonic.cms.business.localization.resource.LocalizationResourceBundleUtils.java
public static String createLocaleString(Locale locale) { String localeString = locale.getLanguage(); return StringUtils.isNotEmpty(locale.getCountry()) ? localeString + "-" + locale.getCountry() : localeString;//from w w w .ja v a2s .c o m }
From source file:Main.java
/** * Create acceptLanguage./* w ww . j a va2 s . com*/ * * @return Returns the client can accept the language types. Such as:zh-CN,zh. */ public static String systemAcceptLanguage() { if (TextUtils.isEmpty(acceptLanguageInstance)) { Locale locale = Locale.getDefault(); String language = locale.getLanguage(); String country = locale.getCountry(); StringBuilder acceptLanguageBuilder = new StringBuilder(language); if (!TextUtils.isEmpty(country)) acceptLanguageBuilder.append('-').append(country).append(',').append(language); acceptLanguageInstance = acceptLanguageBuilder.toString(); } return acceptLanguageInstance; }
From source file:com.omnigon.aem.common.utils.LocaleUtils.java
public static boolean isValidAndNonEnglish(Locale locale) { return locale != null && StringUtils.isNotBlank(locale.getLanguage()) && !StringUtils.equalsIgnoreCase(Locale.ENGLISH.getLanguage(), locale.getLanguage()); }