本文整理汇总了Java中org.languagetool.Language.getLanguageForShortName方法的典型用法代码示例。如果您正苦于以下问题:Java Language.getLanguageForShortName方法的具体用法?Java Language.getLanguageForShortName怎么用?Java Language.getLanguageForShortName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.languagetool.Language
的用法示例。
在下文中一共展示了Language.getLanguageForShortName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentLanguage
import org.languagetool.Language; //导入方法依赖的package包/类
private Language getCurrentLanguage() {
if (autoDetectBox.isSelected()) {
final LanguageIdentifier langIdentifier = new LanguageIdentifier(
textArea.getText());
Language lang = Language.getLanguageForShortName(langIdentifier
.getLanguage());
if (lang == null) {
lang = Language.ENGLISH;
}
for (int i = 0; i < languageBox.getItemCount(); i++) {
final I18nLanguage boxLanguage = (I18nLanguage) languageBox
.getItemAt(i);
if (boxLanguage.toString().equals(
lang.getTranslatedName(messages))) {
languageBox.setSelectedIndex(i);
}
}
return lang;
} else {
return ((I18nLanguage) languageBox.getSelectedItem()).getLanguage();
}
}
示例2: loadConfiguration
import org.languagetool.Language; //导入方法依赖的package包/类
private void loadConfiguration() throws IOException {
try (FileInputStream fis = new FileInputStream(configFile)) {
final Properties props = new Properties();
props.load(fis);
disabledRuleIds.addAll(getListFromProperties(props, DISABLED_RULES_CONFIG_KEY));
enabledRuleIds.addAll(getListFromProperties(props, ENABLED_RULES_CONFIG_KEY));
disabledCategoryNames.addAll(getListFromProperties(props, DISABLED_CATEGORIES_CONFIG_KEY));
final String motherTongueStr = (String) props.get(MOTHER_TONGUE_CONFIG_KEY);
if (motherTongueStr != null) {
motherTongue = Language.getLanguageForShortName(motherTongueStr);
}
final String autoDetectStr = (String) props.get(AUTO_DETECT_CONFIG_KEY);
if (autoDetectStr != null) {
autoDetect = autoDetectStr.equals("true");
}
final String runServerString = (String) props.get(SERVER_RUN_CONFIG_KEY);
if (runServerString != null) {
runServer = runServerString.equals("true");
}
final String serverPortString = (String) props.get(SERVER_PORT_CONFIG_KEY);
if (serverPortString != null) {
serverPort = Integer.parseInt(serverPortString);
}
} catch (final FileNotFoundException e) {
// file not found: okay, leave disabledRuleIds empty
}
}