Java Code Examples for java.util.Locale#TRADITIONAL_CHINESE
The following examples show how to use
java.util.Locale#TRADITIONAL_CHINESE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LanguageUtil.java From FileManager with Apache License 2.0 | 6 votes |
/** * 如果不是英文、简体中文、繁体中文,默认返回英文 * * @return */ private Locale getTragetLocale() { int userType = SharedUtil.getInt(mContext, AppConstant.LANGUAGE); if (userType == LanguageType.FOLLOW_SYSTEM) { Locale sysType = getSysLocale(); if (sysType.equals(Locale.ENGLISH)) { return Locale.ENGLISH; } else if (sysType.equals(Locale.SIMPLIFIED_CHINESE)) { return Locale.SIMPLIFIED_CHINESE; } else if (sysType.equals(Locale.TRADITIONAL_CHINESE)) { return Locale.TRADITIONAL_CHINESE; } return Locale.ENGLISH; } else if (userType == LanguageType.ENGLISH) { return Locale.ENGLISH; } else if (userType == LanguageType.SIMPLE_CHINISE) { return Locale.SIMPLIFIED_CHINESE; } else if (userType == LanguageType.TRADITIONAL_CHINESE) { return Locale.TRADITIONAL_CHINESE; } return Locale.ENGLISH; }
Example 2
Source File: P2PApplication.java From iMoney with Apache License 2.0 | 6 votes |
/** * 设置语言:如果之前有设置就遵循设置如果没设置过就跟随系统语言 */ private void changeAppLanguage() { int currentLanguage = SpUtil.getInstance(mContext) .getInt(SpKey.CURRENT_LANGUAGE, -1); Locale myLocale; // 0 简体中文 1 繁体中文 2 English switch (currentLanguage) { case 0: myLocale = Locale.SIMPLIFIED_CHINESE; break; case 1: myLocale = Locale.TRADITIONAL_CHINESE; break; case 2: myLocale = Locale.ENGLISH; break; default: myLocale = getResources().getConfiguration().locale; } // 本地语言设置 if (LocaleUtils.needUpdateLocale(this, myLocale)) { LocaleUtils.updateLocale(this, myLocale); } }
Example 3
Source File: ResourceHolder.java From database-transform-tool with Apache License 2.0 | 6 votes |
/** * <pre> * 描述:获取本地语言 * 作者:ZhangYi * 时间:2015年1月30日 下午1:24:06 * 参数:(参数列表) * @param language * @return * </pre> */ public static Locale getLocale(String language) { Locale locale = Locale.CHINESE; if (!StringUtil.isEmpty(language)) { language = language.toLowerCase(); if (language.indexOf("en") != -1) { locale = Locale.ENGLISH; } if (language.indexOf("zh_hk") != -1) { locale = Locale.TRADITIONAL_CHINESE; } if (language.indexOf("zh_cn") != -1) { locale = Locale.SIMPLIFIED_CHINESE; } } return locale; }
Example 4
Source File: LocaleUtils.java From iMoney with Apache License 2.0 | 6 votes |
/** * 获取用户设置的Locale * * @param pContext Context * @return Locale */ public static Locale getUserLocale(Context pContext) { int currentLanguage = SpUtil.getInstance(CommonApplication.getContext()) .getInt(SpKey.CURRENT_LANGUAGE, 0); Locale myLocale = Locale.SIMPLIFIED_CHINESE; switch (currentLanguage) { case 0: myLocale = Locale.SIMPLIFIED_CHINESE; break; case 1: myLocale = Locale.ENGLISH; break; case 2: myLocale = Locale.TRADITIONAL_CHINESE; break; } return myLocale; }
Example 5
Source File: LocaleMappingTest.java From morphia with Apache License 2.0 | 6 votes |
@Test public void testLocaleMapping() { E e = new E(); e.l1 = Locale.CANADA_FRENCH; e.l2 = Arrays.asList(Locale.GERMANY, Locale.TRADITIONAL_CHINESE); e.l3 = new Locale[]{Locale.TRADITIONAL_CHINESE, Locale.FRENCH}; getDs().save(e); final Datastore datastore = getDs(); e = datastore.find(E.class) .filter(eq("_id", e.id)) .first(); Assert.assertEquals(Locale.CANADA_FRENCH, e.l1); Assert.assertEquals(2, e.l2.size()); Assert.assertEquals(Locale.GERMANY, e.l2.get(0)); Assert.assertEquals(Locale.TRADITIONAL_CHINESE, e.l2.get(1)); Assert.assertEquals(2, e.l3.length); Assert.assertEquals(Locale.TRADITIONAL_CHINESE, e.l3[0]); Assert.assertEquals(Locale.FRENCH, e.l3[1]); }
Example 6
Source File: UtilTest.java From calcite with Apache License 2.0 | 6 votes |
/** * Unit test for {@link Util#parseLocale(String)} method. */ @Test void testParseLocale() { Locale[] locales = { Locale.CANADA, Locale.CANADA_FRENCH, Locale.getDefault(), Locale.US, Locale.TRADITIONAL_CHINESE, Locale.ROOT, }; for (Locale locale : locales) { assertEquals(locale, Util.parseLocale(locale.toString())); } // Example locale names in Locale.toString() javadoc. String[] localeNames = { "en", "de_DE", "_GB", "en_US_WIN", "de__POSIX", "fr__MAC" }; for (String localeName : localeNames) { assertEquals(localeName, Util.parseLocale(localeName).toString()); } }
Example 7
Source File: Support.java From FreezeYou with Apache License 2.0 | 6 votes |
private static Locale getLocal(Context context) { String s = PreferenceManager.getDefaultSharedPreferences(context).getString("languagePref", "Default"); if (s == null) { s = "Default"; } switch (s) { case "tc": return Locale.TRADITIONAL_CHINESE; case "sc": return Locale.SIMPLIFIED_CHINESE; case "en": return Locale.ENGLISH; case "Default": default: return Locale.getDefault(); } }
Example 8
Source File: LocaleTransform.java From PictureSelector with Apache License 2.0 | 5 votes |
public static Locale getLanguage(int language) { switch (language) { case LanguageConfig.ENGLISH: // 英语-美国 return Locale.ENGLISH; case LanguageConfig.TRADITIONAL_CHINESE: // 繁体中文 return Locale.TRADITIONAL_CHINESE; case LanguageConfig.KOREA: // 韩语 return Locale.KOREA; case LanguageConfig.GERMANY: // 德语 return Locale.GERMANY; case LanguageConfig.FRANCE: // 法语 return Locale.FRANCE; case LanguageConfig.JAPAN: // 日语 return Locale.JAPAN; case LanguageConfig.VIETNAM: // 越南语 return new Locale("vi"); default: // 简体中文 return Locale.CHINESE; } }
Example 9
Source File: ExampleUnitTest.java From android with MIT License | 5 votes |
@Test public void testStringLocale() throws Exception { Locale[] locales = new Locale[]{ Locale.CANADA, Locale.CANADA_FRENCH, Locale.CHINESE, Locale.ENGLISH, Locale.FRANCE, Locale.GERMAN, Locale.GERMANY, Locale.ITALIAN, Locale.ITALY, Locale.JAPAN, Locale.JAPANESE, Locale.KOREA, Locale.KOREAN, Locale.PRC, Locale.ROOT, Locale.SIMPLIFIED_CHINESE, Locale.TAIWAN, Locale.TRADITIONAL_CHINESE, Locale.UK, Locale.US }; String weightString = null; for (Locale locale : locales) { try { weightString = formatFloatWithOneDot(locale, 55.4f); float weight = Float.parseFloat(weightString); } catch (NumberFormatException e) { System.out.println(locale + ">>>>>" + weightString + ">>>>>>>>>> error"); continue; } System.out.println(locale + ">>>>>" + weightString); } }
Example 10
Source File: LocaleUtils.java From dubbox with Apache License 2.0 | 5 votes |
public static Locale getLocale(String language) { if ("en".equalsIgnoreCase(language)) { return Locale.ENGLISH; } else if ("zh".equalsIgnoreCase(language)) { return Locale.SIMPLIFIED_CHINESE; } else if ("zh_TW".equalsIgnoreCase(language)) { return Locale.TRADITIONAL_CHINESE; } return Locale.getDefault(); }
Example 11
Source File: LanguageUtils.java From scoold with Apache License 2.0 | 5 votes |
/** * Returns a non-null locale for a given language code. * @param langCode the 2-letter language code * @return a locale. default is English */ public Locale getProperLocale(String langCode) { if (StringUtils.startsWith(langCode, "zh")) { if ("zh_tw".equalsIgnoreCase(langCode)) { return Locale.TRADITIONAL_CHINESE; } else { return Locale.SIMPLIFIED_CHINESE; } } String lang = StringUtils.substring(langCode, 0, 2); lang = (StringUtils.isBlank(lang) || !ALL_LOCALES.containsKey(lang)) ? "en" : lang.trim().toLowerCase(); return ALL_LOCALES.get(lang); }
Example 12
Source File: LocaleUtils.java From dubbox with Apache License 2.0 | 5 votes |
public static Locale getLocale(String language) { if ("en".equalsIgnoreCase(language)) { return Locale.ENGLISH; } else if ("zh".equalsIgnoreCase(language)) { return Locale.SIMPLIFIED_CHINESE; } else if ("zh_TW".equalsIgnoreCase(language)) { return Locale.TRADITIONAL_CHINESE; } return Locale.getDefault(); }
Example 13
Source File: LocaleUtils.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public static Locale getLocale(String language) { if ("en".equalsIgnoreCase(language)) { return Locale.ENGLISH; } else if ("zh".equalsIgnoreCase(language)) { return Locale.SIMPLIFIED_CHINESE; } else if ("zh_TW".equalsIgnoreCase(language)) { return Locale.TRADITIONAL_CHINESE; } return Locale.getDefault(); }
Example 14
Source File: MessageCatalog.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private Locale getLocale(String localeName) { String language, country; int index; index = localeName.indexOf('_'); if (index == -1) { // // Special case the builtin JDK languages // if (localeName.equals("de")) return Locale.GERMAN; if (localeName.equals("en")) return Locale.ENGLISH; if (localeName.equals("fr")) return Locale.FRENCH; if (localeName.equals("it")) return Locale.ITALIAN; if (localeName.equals("ja")) return Locale.JAPANESE; if (localeName.equals("ko")) return Locale.KOREAN; if (localeName.equals("zh")) return Locale.CHINESE; language = localeName; country = ""; } else { if (localeName.equals("zh_CN")) return Locale.SIMPLIFIED_CHINESE; if (localeName.equals("zh_TW")) return Locale.TRADITIONAL_CHINESE; // // JDK also has constants for countries: en_GB, en_US, en_CA, // fr_FR, fr_CA, de_DE, ja_JP, ko_KR. We don't use those. // language = localeName.substring(0, index); country = localeName.substring(index + 1); } return new Locale(language, country); }
Example 15
Source File: MessageCatalog.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private Locale getLocale(String localeName) { String language, country; int index; index = localeName.indexOf('_'); if (index == -1) { // // Special case the builtin JDK languages // if (localeName.equals("de")) return Locale.GERMAN; if (localeName.equals("en")) return Locale.ENGLISH; if (localeName.equals("fr")) return Locale.FRENCH; if (localeName.equals("it")) return Locale.ITALIAN; if (localeName.equals("ja")) return Locale.JAPANESE; if (localeName.equals("ko")) return Locale.KOREAN; if (localeName.equals("zh")) return Locale.CHINESE; language = localeName; country = ""; } else { if (localeName.equals("zh_CN")) return Locale.SIMPLIFIED_CHINESE; if (localeName.equals("zh_TW")) return Locale.TRADITIONAL_CHINESE; // // JDK also has constants for countries: en_GB, en_US, en_CA, // fr_FR, fr_CA, de_DE, ja_JP, ko_KR. We don't use those. // language = localeName.substring(0, index); country = localeName.substring(index + 1); } return new Locale(language, country); }
Example 16
Source File: MessageCatalog.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private Locale getLocale(String localeName) { String language, country; int index; index = localeName.indexOf('_'); if (index == -1) { // // Special case the builtin JDK languages // if (localeName.equals("de")) return Locale.GERMAN; if (localeName.equals("en")) return Locale.ENGLISH; if (localeName.equals("fr")) return Locale.FRENCH; if (localeName.equals("it")) return Locale.ITALIAN; if (localeName.equals("ja")) return Locale.JAPANESE; if (localeName.equals("ko")) return Locale.KOREAN; if (localeName.equals("zh")) return Locale.CHINESE; language = localeName; country = ""; } else { if (localeName.equals("zh_CN")) return Locale.SIMPLIFIED_CHINESE; if (localeName.equals("zh_TW")) return Locale.TRADITIONAL_CHINESE; // // JDK also has constants for countries: en_GB, en_US, en_CA, // fr_FR, fr_CA, de_DE, ja_JP, ko_KR. We don't use those. // language = localeName.substring(0, index); country = localeName.substring(index + 1); } return new Locale(language, country); }
Example 17
Source File: MessageCatalog.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private Locale getLocale(String localeName) { String language, country; int index; index = localeName.indexOf('_'); if (index == -1) { // // Special case the builtin JDK languages // if (localeName.equals("de")) return Locale.GERMAN; if (localeName.equals("en")) return Locale.ENGLISH; if (localeName.equals("fr")) return Locale.FRENCH; if (localeName.equals("it")) return Locale.ITALIAN; if (localeName.equals("ja")) return Locale.JAPANESE; if (localeName.equals("ko")) return Locale.KOREAN; if (localeName.equals("zh")) return Locale.CHINESE; language = localeName; country = ""; } else { if (localeName.equals("zh_CN")) return Locale.SIMPLIFIED_CHINESE; if (localeName.equals("zh_TW")) return Locale.TRADITIONAL_CHINESE; // // JDK also has constants for countries: en_GB, en_US, en_CA, // fr_FR, fr_CA, de_DE, ja_JP, ko_KR. We don't use those. // language = localeName.substring(0, index); country = localeName.substring(index + 1); } return new Locale(language, country); }
Example 18
Source File: ChineseZhuyinKeyboard.java From FirefoxReality with Mozilla Public License 2.0 | 4 votes |
@Override public Locale getLocale() { return Locale.TRADITIONAL_CHINESE; }
Example 19
Source File: MessageCatalog.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private Locale getLocale(String localeName) { String language, country; int index; index = localeName.indexOf('_'); if (index == -1) { // // Special case the builtin JDK languages // if (localeName.equals("de")) return Locale.GERMAN; if (localeName.equals("en")) return Locale.ENGLISH; if (localeName.equals("fr")) return Locale.FRENCH; if (localeName.equals("it")) return Locale.ITALIAN; if (localeName.equals("ja")) return Locale.JAPANESE; if (localeName.equals("ko")) return Locale.KOREAN; if (localeName.equals("zh")) return Locale.CHINESE; language = localeName; country = ""; } else { if (localeName.equals("zh_CN")) return Locale.SIMPLIFIED_CHINESE; if (localeName.equals("zh_TW")) return Locale.TRADITIONAL_CHINESE; // // JDK also has constants for countries: en_GB, en_US, en_CA, // fr_FR, fr_CA, de_DE, ja_JP, ko_KR. We don't use those. // language = localeName.substring(0, index); country = localeName.substring(index + 1); } return new Locale(language, country); }
Example 20
Source File: MessageCatalog.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private Locale getLocale(String localeName) { String language, country; int index; index = localeName.indexOf('_'); if (index == -1) { // // Special case the builtin JDK languages // if (localeName.equals("de")) return Locale.GERMAN; if (localeName.equals("en")) return Locale.ENGLISH; if (localeName.equals("fr")) return Locale.FRENCH; if (localeName.equals("it")) return Locale.ITALIAN; if (localeName.equals("ja")) return Locale.JAPANESE; if (localeName.equals("ko")) return Locale.KOREAN; if (localeName.equals("zh")) return Locale.CHINESE; language = localeName; country = ""; } else { if (localeName.equals("zh_CN")) return Locale.SIMPLIFIED_CHINESE; if (localeName.equals("zh_TW")) return Locale.TRADITIONAL_CHINESE; // // JDK also has constants for countries: en_GB, en_US, en_CA, // fr_FR, fr_CA, de_DE, ja_JP, ko_KR. We don't use those. // language = localeName.substring(0, index); country = localeName.substring(index + 1); } return new Locale(language, country); }