Java Code Examples for java.util.Locale#SIMPLIFIED_CHINESE

The following examples show how to use java.util.Locale#SIMPLIFIED_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: Text.java    From gameserver with Apache License 2.0 6 votes vote down vote up
/**
 * Get a composed i18n string with given arguments.
 * @param key
 * @param argument
 * @return
 */
public static final String text(String key, Object ... argument) {
	Locale userLocale = Locale.SIMPLIFIED_CHINESE;
	if ( Constant.I18N_ENABLE ) {
		LocaleThreadLocal threadLocal = GameContext.getInstance().getLocaleThreadLocal();
		userLocale = threadLocal.get();
		if ( userLocale == null ) {
			userLocale = Locale.SIMPLIFIED_CHINESE;
			//threadLocal.set(userLocale);
		}
	}
	ResourceBundle bundle = CHINESE;
	if ( Locale.TRADITIONAL_CHINESE.equals(userLocale) ) {
		bundle = TAIWAN;
	}
	return text(key, bundle, argument);
}
 
Example 2
Source File: Text.java    From gameserver with Apache License 2.0 6 votes vote down vote up
/**
 * Get a composed i18n string with given arguments.
 * @param key
 * @param argument
 * @return
 */
public static final String text(String key, Object arg1, Object arg2) {
	Locale userLocale = Locale.SIMPLIFIED_CHINESE;
	if ( Constant.I18N_ENABLE ) {
		LocaleThreadLocal threadLocal = GameContext.getInstance().getLocaleThreadLocal();
		userLocale = threadLocal.get();
		if ( userLocale == null ) {
			userLocale = Locale.SIMPLIFIED_CHINESE;
			//threadLocal.set(userLocale);
		}
	}
	ResourceBundle bundle = CHINESE;
	if ( Locale.TRADITIONAL_CHINESE.equals(userLocale) ) {
		bundle = TAIWAN;
	}
	return text(key, bundle, new Object[]{arg1, arg2});
}
 
Example 3
Source File: LanguageUtil.java    From FileManager with Apache License 2.0 6 votes vote down vote up
/**
 * 如果不是英文、简体中文、繁体中文,默认返回英文
 *
 * @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 4
Source File: Text.java    From gameserver with Apache License 2.0 6 votes vote down vote up
/**
 * Get a composed i18n string with given arguments.
 * @param key
 * @param argument
 * @return
 */
public static final String text(String key, Object argument) {
	Locale userLocale = Locale.SIMPLIFIED_CHINESE;
	if ( Constant.I18N_ENABLE ) {
		LocaleThreadLocal threadLocal = GameContext.getInstance().getLocaleThreadLocal();
		userLocale = threadLocal.get();
		if ( userLocale == null ) {
			userLocale = Locale.SIMPLIFIED_CHINESE;
			//threadLocal.set(userLocale);
		}
	}
	ResourceBundle bundle = CHINESE;
	if ( Locale.TRADITIONAL_CHINESE.equals(userLocale) ) {
		bundle = TAIWAN;
	}
	return text(key, bundle, new Object[]{argument});
}
 
Example 5
Source File: MultiLanguageUtil.java    From AndroidMultiLanguage with Apache License 2.0 6 votes vote down vote up
/**
 * 如果不是英文、简体中文、繁体中文,默认返回简体中文
 *
 * @return
 */
private Locale getLanguageLocale() {
    int languageType = CommSharedUtil.getInstance(mContext).getInt(MultiLanguageUtil.SAVE_LANGUAGE, 0);
    if (languageType == LanguageType.LANGUAGE_FOLLOW_SYSTEM) {
        Locale sysLocale= getSysLocale();
        return sysLocale;
    } else if (languageType == LanguageType.LANGUAGE_EN) {
        return Locale.ENGLISH;
    } else if (languageType == LanguageType.LANGUAGE_CHINESE_SIMPLIFIED) {
        return Locale.SIMPLIFIED_CHINESE;
    } else if (languageType == LanguageType.LANGUAGE_CHINESE_TRADITIONAL) {
        return Locale.TRADITIONAL_CHINESE;
    }
    getSystemLanguage(getSysLocale());
    Log.e(TAG, "getLanguageLocale" + languageType + languageType);
    return Locale.SIMPLIFIED_CHINESE;
}
 
Example 6
Source File: DirectionChangeView.java    From flow with Apache License 2.0 6 votes vote down vote up
@Override
protected void onAttach(AttachEvent attachEvent) {
    super.onAttach(attachEvent);

    locale.setText(attachEvent.getUI().getLocale().toString());
    locale.setId("initial-direction");

    NativeButton changeLocale = new NativeButton(
            "Swap location to " + Locale.SIMPLIFIED_CHINESE,
            event -> attachEvent.getUI()
                    .setLocale(Locale.SIMPLIFIED_CHINESE));
    changeLocale.setId("locale-button");

    NativeButton ltrButton = new NativeButton(
            "Swap to " + Direction.LEFT_TO_RIGHT, event -> attachEvent
                    .getUI().setDirection(Direction.LEFT_TO_RIGHT));
    ltrButton.setId("ltr-button");
    NativeButton rtlButton = new NativeButton(
            "Swap to " + Direction.RIGHT_TO_LEFT, event -> attachEvent
                    .getUI().setDirection(Direction.RIGHT_TO_LEFT));
    rtlButton.setId("rtl-button");
    add(locale, ltrButton, rtlButton, changeLocale);
}
 
Example 7
Source File: DateUtil.java    From HA-DB with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 将传入时间格式化成 yyyy-MM-dd 格式字符串
 */
public static String dateStr(Date _Date) {
	if (_Date == null)
		return "";
	SimpleDateFormat _SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd",
			Locale.SIMPLIFIED_CHINESE);
	return _SimpleDateFormat.format(_Date);
}
 
Example 8
Source File: CalendarAdapter.java    From calendar with Apache License 2.0 5 votes vote down vote up
public void setRange(String sTime, String eTime, String format, boolean clean, boolean notify) {
    Date[] dates = new Date[2];
    try {
        SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.SIMPLIFIED_CHINESE);
        dates[0] = sdf.parse(sTime);
        dates[1] = sdf.parse(eTime);
    } catch (Exception e) {
        e.printStackTrace();
    }
    setRange(dates[0], dates[1], clean, notify);
}
 
Example 9
Source File: ExampleUnitTest.java    From android with MIT License 5 votes vote down vote up
@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: TimeUtil.java    From lunzi with Apache License 2.0 5 votes vote down vote up
public static long getDateTimeString2Long(String dt, String pattern) {
	SimpleDateFormat dateformat = new SimpleDateFormat(pattern, Locale.SIMPLIFIED_CHINESE);
	Date date2 = null;
	try {
		date2 = dateformat.parse(dt);// 
	} catch (ParseException e) {
		return 0;
	}
	return date2.getTime();
}
 
Example 11
Source File: SessionManager.java    From gameserver with Apache License 2.0 5 votes vote down vote up
/**
 * Find the user's machine id by his/her userId
 * @param userId
 * @return
 */
public Locale findUserLocale(SessionKey sessionKey) {
	if ( sessionKey == null ) return Locale.SIMPLIFIED_CHINESE;
	Jedis jedis = JedisFactory.getJedis();
	String locale = jedis.hget(sessionKey.toString(), H_LOCALE_KEY);
	return StringUtil.parseLocale(locale, Locale.SIMPLIFIED_CHINESE);
}
 
Example 12
Source File: LocaleUtils.java    From dubbox with Apache License 2.0 5 votes vote down vote up
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: P2PApplication.java    From iMoney with Apache License 2.0 5 votes vote down vote up
/**
 * 当系统语言发生改变的时候还是继续遵循用户设置的语言
 *
 * @param newConfig
 */
@SuppressLint("ObsoleteSdkInt")
private void setLanguage(Configuration newConfig) {
    int currentLanguage = SpUtil.getInstance(mContext)
            .getInt(SpKey.CURRENT_LANGUAGE, -1);
    Locale userLocale;
    // 0 简体中文 1 繁体中文 2 English
    switch (currentLanguage) {
        case 0:
            userLocale = Locale.SIMPLIFIED_CHINESE;
            break;
        case 1:
            userLocale = Locale.TRADITIONAL_CHINESE;
            break;
        case 2:
            userLocale = Locale.ENGLISH;
            break;
        default:
            userLocale = getResources().getConfiguration().locale;
    }
    // 系统语言改变了应用保持之前设置的语言
    if (userLocale != null) {
        Locale.setDefault(userLocale);
        Configuration configuration = new Configuration(newConfig);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            configuration.setLocale(userLocale);
        } else {
            configuration.locale = userLocale;
        }
        getResources().updateConfiguration(configuration, getResources().getDisplayMetrics());
    }
}
 
Example 14
Source File: DirectionChangeView.java    From flow with Apache License 2.0 5 votes vote down vote up
@Override
public void localeChange(LocaleChangeEvent event) {
    if (event.getLocale()== Locale.SIMPLIFIED_CHINESE) {
        event.getUI().setDirection(Direction.RIGHT_TO_LEFT);
    }
    locale.setText(event.getLocale().toString());
}
 
Example 15
Source File: LocaleUtils.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
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 16
Source File: DateUtil.java    From HA-DB with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * 将传入的时间字符串转换成时间格式
 */
public static Date formatDate2(String _Date) throws ParseException {
	SimpleDateFormat _SimpleDateFormat = new SimpleDateFormat(
			"yyyy:MM:dd HH:mm:ss", Locale.SIMPLIFIED_CHINESE);
	return _SimpleDateFormat.parse(_Date);
}
 
Example 17
Source File: MessageCatalog.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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: MessageCatalog.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
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 19
Source File: SessionDelegateMessageBundle.java    From super-cloudops with Apache License 2.0 4 votes vote down vote up
@Override
protected Locale getSessionLocale() {
	Locale locale = (Locale) getBindValue(KEY_LANG_NAME);
	return Objects.isNull(locale) ? Locale.SIMPLIFIED_CHINESE : locale;
}
 
Example 20
Source File: MessageCatalog.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
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);
}