本文整理汇总了Java中org.omegat.util.Language类的典型用法代码示例。如果您正苦于以下问题:Java Language类的具体用法?Java Language怎么用?Java Language使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Language类属于org.omegat.util包,在下文中一共展示了Language类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: genXliff
import org.omegat.util.Language; //导入依赖的package包/类
private String genXliff(Language sLang, Language tLang, String text) {
++transUnitId;
if (settings.getBoolean("filter", false)) {
text = text.replaceAll("<\\/?[a-z]\\d+>", "");
}
String xliff
= "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
+ "<xliff version=\"1.2\">\n"
+ " <file source-language=\"" + sLang + "\" target-language=\"" + tLang + "\">\n"
+ " <header>\n"
+ " <note from=\"PTTOOLS\">\n"
+ " <graphname>" + settings.get("engine", null) + "</graphname>\n"
+ " </note>\n"
+ " </header>\n"
+ " <body>\n"
+ " <trans-unit id=\"" + Long.toString(transUnitId) + "\">\n"
+ " <source>" + StringEscapeUtils.escapeXml10(text) + "</source>\n"
+ " </trans-unit>\n"
+ " </body>\n"
+ " </file>\n"
+ "</xliff>\n";
return xliff;
}
示例2: testIsFileSupported_true
import org.omegat.util.Language; //导入依赖的package包/类
@Test
void testIsFileSupported_true() throws Exception {
OmegatMarkdownFilter mdf = new OmegatMarkdownFilter();
File target = new File(this.getClass().getResource("/source/case0.md").getFile());
FilterContext fc = new FilterContext(new Language("en"), new Language("be"), true);
assertTrue(mdf.isFileSupported(target, null, fc));
}
示例3: testIsFileSupported_false
import org.omegat.util.Language; //导入依赖的package包/类
@Test
void testIsFileSupported_false() throws Exception {
OmegatMarkdownFilter mdf = new OmegatMarkdownFilter();
File target = new File(this.getClass().getResource("/source/nomarkdown.txt").getFile());
FilterContext fc = new FilterContext(new Language("en"), new Language("be"), true);
assertFalse(mdf.isFileSupported(target, null, fc));
}
示例4: translate
import org.omegat.util.Language; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected String translate(Language sLang, Language tLang, String text) throws Exception {
String xliff = genXliff(sLang, tLang, text);
XmlRpcClient client = setUpClient();
try {
Object[] params = new Object[]{new Object[]{xliff}};
Object[] runResults = (Object[]) client.execute("run", params);
String jobId = (String) runResults[0];
if (!jobId.equals("")) {
params = new Object[]{new Object[]{jobId}, false, true, settings.getBoolean("delete", true)};
Map<String, Map> statusResults;
String status;
do {
statusResults = (Map<String, Map>) client.execute("status", params);
status = (String) statusResults.get(jobId).get("status");
} while (!status.equals("completed") && !status.equals("failed"));
Object[] contents = (Object[]) statusResults.get(jobId).get("content");
if (status.equals("completed") && contents.length != 0) {
String transXliff = (String) contents[0];
Pattern p = Pattern.compile("state=\"new\">(.*)</target>", Pattern.MULTILINE);
Matcher m = p.matcher(transXliff);
if (m.find()) {
String transUnit = StringEscapeUtils.unescapeXml(m.group(1));
return transUnit;
}
}
} else {
return "ERROR!\n" + "Missing graph or invalid configurations";
}
} catch (XmlRpcException ex) {
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
return "ERROR!\n" + ex.getMessage();
}
return xliff;
}
示例5: translate
import org.omegat.util.Language; //导入依赖的package包/类
@Override
protected String translate(Language sLang, Language tLang, String text) throws Exception {
String server = System.getProperty("moses.server.url");
if (server == null) {
return "The Moses server address is not available.";
}
Map<String, String> mosesParams = new HashMap<String, String>();
XmlRpcClient client = new XmlRpcClient();
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL(server));
client.setConfig(config);
mosesParams.put("text", mosesPreprocess(text, sLang.getLocale()));
Object[] xmlRpcParams = new Object[] { mosesParams };
String result;
try {
HashMap<?, ?> response = (HashMap<?, ?>) client.execute("translate", xmlRpcParams);
result = (String) response.get("text");
} catch (XmlRpcException e) {
return e.getLocalizedMessage();
}
return mosesPostprocess(result, tLang);
}
示例6: mosesPostprocess
import org.omegat.util.Language; //导入依赖的package包/类
private String mosesPostprocess(String text, Language targetLanguage) {
String result = CharacterReference.decode(text);
result = DeNormalize.processSingleLine(result).replaceAll("\\s+", " ").trim();
if (!targetLanguage.isSpaceDelimited()) {
result = result.replaceAll("(?<=[\u3001-\u9fa0])\\s+(?=[\u3001-\u9fa0])", "");
}
return cleanSpacesAroundTags(result, text);
}
示例7: translate
import org.omegat.util.Language; //导入依赖的package包/类
@Override
protected String translate(Language sLang, Language tLang, String text) throws Exception {
return LocalApertiumTranslate.translateApertiumLocalInstallation(text);
}
示例8: massTranslate
import org.omegat.util.Language; //导入依赖的package包/类
public List<String> massTranslate(Language sLang, Language tLang, List<String> texts) throws Exception {
return LocalApertiumTranslate.translateApertiumLocalInstallation(texts);
}
示例9: getSourceLanguage
import org.omegat.util.Language; //导入依赖的package包/类
public Language getSourceLanguage() {
return new Language("en");
}
示例10: getTargetLanguage
import org.omegat.util.Language; //导入依赖的package包/类
public Language getTargetLanguage() {
return new Language("pl");
}
示例11: translate
import org.omegat.util.Language; //导入依赖的package包/类
public String translate(Language sLang, Language tLang, String text)
throws Exception {return "";}
示例12: getTranslation
import org.omegat.util.Language; //导入依赖的package包/类
public String getTranslation(Language sLang, Language tLang, String text)
throws Exception {return "";}
示例13: getTranslation
import org.omegat.util.Language; //导入依赖的package包/类
/**
* Translate.
*
* @param sLang
* source language
* @param tLang
* target language
* @param text
* text for translation
* @return translated text, or null if translation impossible
*/
String getTranslation(Language sLang, Language tLang, String text) throws Exception;
示例14: getTranslation
import org.omegat.util.Language; //导入依赖的package包/类
String getTranslation(Language sLang, Language tLang, String text) throws Exception;
示例15: getTranslation
import org.omegat.util.Language; //导入依赖的package包/类
public String getTranslation(Language sLang, Language tLang, String text) {return null;}