当前位置: 首页>>代码示例>>Java>>正文


Java Language.toString方法代码示例

本文整理汇总了Java中com.memetix.mst.language.Language.toString方法的典型用法代码示例。如果您正苦于以下问题:Java Language.toString方法的具体用法?Java Language.toString怎么用?Java Language.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.memetix.mst.language.Language的用法示例。


在下文中一共展示了Language.toString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processLanguage

import com.memetix.mst.language.Language; //导入方法依赖的package包/类
/** 处理语言 */
public static Language processLanguage(String hsLanguageCode) {
	// 由于中文前缀一样,需针对中文特殊处理。
	if (hsLanguageCode.equalsIgnoreCase("zh-CN")) {
		return Language.CHINESE_SIMPLIFIED;
	}

	if (hsLanguageCode.equalsIgnoreCase("zh-TW") || hsLanguageCode.equalsIgnoreCase("zh-HK")) {
		return Language.CHINESE_TRADITIONAL;
	}
	
	Language[] supportedLangs = Language.values();
	for (Language lang : supportedLangs) {
		String code = lang.toString();
		if (code.equals("")) {
			continue;
		}

		if (hsLanguageCode.startsWith(code) || code.startsWith(hsLanguageCode)) {
			return lang;
		}
	}
	return null;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:25,代码来源:BingTransUtils.java

示例2: obtainLanguagesBingAPI

import com.memetix.mst.language.Language; //导入方法依赖的package包/类
private void obtainLanguagesBingAPI(List<LanguagesOutput> outputList,
		List<LanguagesInput> inputList) throws ForecatException {
	int pos;
	if ((pos = LanguagesInput.searchEngine(inputList, Engine.BING.toString())) != -1) {
		// Client ID and client secret are separated by the first comma:
		String[] s = inputList.get(pos).getKey().split(",", 2);

		if (s.length != 2) {
			throw new ForecatException(
					"LanguagesServer: wrong formatted id and secret for Bing");
		}
		Translate.setClientId(s[0]);
		Translate.setClientSecret(s[1]);

		// Translate.setClientId("bbcat");
		// TODO: do not publish keys in the repository
		// Translate.setClientSecret("lndluhebDf++b0eouRJrHw5NRww80RaxfCwdV0yjIts=");

		// Getting language names from Bing:
		// for(Language lang : Language.values()) System.out.println(lang.name() + " : " +
		// lang.toString() + " : " + lang.getName(Language.ENGLISH));

		// Note that generating all possible combinations raises the number of language pairs
		// over 1000 and consequently serializing all of them in development mode will take some
		// time:
		// http://stackoverflow.com/questions/4799501/why-gwt-devmode-serialization-is-hundred-times-slower
		for (Language lang : Language.values()) {
			for (Language lang2 : Language.values()) {
				String sourceCode = lang.toString();
				String targetCode = lang2.toString();
				// Bing translates between all the possible language
				// combinations
				if (!sourceCode.equals(targetCode)) {
					addLanguagePair(outputList, sourceCode, targetCode, Engine.BING.toString());
				}
			}
		}
	}
}
 
开发者ID:transducens,项目名称:forecat,代码行数:40,代码来源:LanguagesServerSide.java


注:本文中的com.memetix.mst.language.Language.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。