use of org.omegat.util.Language in project omegat by omegat-org.
the class SegmenterTest method testSegment.
/**
* Test of segment method, of class org.omegat.core.segmentation.Segmenter.
*/
@Test
public void testSegment() {
List<StringBuilder> spaces = new ArrayList<StringBuilder>();
List<String> segments = segmenter.segment(new Language("en"), "<br7>\n\n<br5>\n\nother", spaces, new ArrayList<Rule>());
assertEquals(3, segments.size());
assertEquals("<br7>", segments.get(0));
assertEquals("<br5>", segments.get(1));
assertEquals("other", segments.get(2));
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class SegmenterTest method getPseudoTranslationFromEnToJa.
private String getPseudoTranslationFromEnToJa(final String source) {
final String enFullstop = ".";
final String jaFullstop = "\\u3002";
List<StringBuilder> spaces = new ArrayList<StringBuilder>();
List<Rule> brules = new ArrayList<Rule>();
List<String> segments = segmenter.segment(new Language("en"), source, spaces, brules);
// pseudo-translation (just replace full-stop char)
for (int i = 0; i < segments.size(); i++) {
segments.set(i, segments.get(i).replace(enFullstop, jaFullstop));
}
return segmenter.glue(new Language("en"), new Language("ja"), segments, spaces, brules);
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class HTMLFilter2Test method testTagsOptimization.
@Test
public void testTagsOptimization() throws Exception {
String f = "test/data/filters/html/file-HTMLFilter2-tags-optimization.html";
HTMLFilter2 filter = new HTMLFilter2();
Core.getFilterMaster().getConfig().setRemoveTags(false);
filter.isFileSupported(new File(f), Collections.emptyMap(), new FilterContext(new Language("en"), new Language("be"), false));
IProject.FileInfo fi = loadSourceFiles(filter, f);
checkMultiStart(fi, f);
checkMultiNoPrevNext("<i0/><b1><c2>This</c2> is <i3>first</i3> line.</b1>", null, null, null);
translateXML(filter, f);
Core.getFilterMaster().getConfig().setRemoveTags(true);
filter.isFileSupported(new File(f), Collections.emptyMap(), new FilterContext(new Language("en"), new Language("be"), false));
fi = loadSourceFiles(filter, f);
checkMultiStart(fi, f);
checkMultiNoPrevNext("<c0>This</c0> is <i1>first</i1> line.", null, null, null);
translateXML(filter, f);
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class XHTMLFilterTest method testLoad.
@Test
public void testLoad() throws Exception {
String f = "test/data/filters/xhtml/file-XHTMLFilter.html";
XHTMLFilter filter = new XHTMLFilter();
filter.isFileSupported(new File(f), new TreeMap<String, String>(), new FilterContext(new Language("en"), new Language("be"), false));
IProject.FileInfo fi = loadSourceFiles(filter, f);
checkMultiStart(fi, f);
checkMulti("en", null, null, "", "en", null);
checkMulti("en", null, null, "en", "XHTML 1.0 Example", null);
checkMulti("XHTML 1.0 Example", null, null, "en", "Extensible HyperText Markup Language", null);
checkMulti("Extensible HyperText Markup Language", null, null, "XHTML 1.0 Example", "http://www.w3.org/Icons/valid-xhtml10", null);
}
use of org.omegat.util.Language in project omegat by omegat-org.
the class XHTMLFilterTest method testTagsOptimization.
@Test
public void testTagsOptimization() throws Exception {
String f = "test/data/filters/xhtml/file-XHTMLFilter-tags-optimization.html";
XHTMLFilter filter = new XHTMLFilter();
Core.getFilterMaster().getConfig().setRemoveTags(false);
filter.isFileSupported(new File(f), new TreeMap<String, String>(), new FilterContext(new Language("en"), new Language("be"), false));
IProject.FileInfo fi = loadSourceFiles(filter, f);
checkMultiStart(fi, f);
checkMultiNoPrevNext("en", null, null, null);
checkMultiNoPrevNext("en", null, null, null);
checkMultiNoPrevNext("<i0/><b1><c2>This</c2> is <i3>first</i3> line.</b1>", null, null, null);
translateXML(filter, f);
Core.getFilterMaster().getConfig().setRemoveTags(true);
filter.isFileSupported(new File(f), new TreeMap<String, String>(), new FilterContext(new Language("en"), new Language("be"), false));
fi = loadSourceFiles(filter, f);
checkMultiStart(fi, f);
checkMultiNoPrevNext("en", null, null, null);
checkMultiNoPrevNext("en", null, null, null);
checkMultiNoPrevNext("<c0>This</c0> is <i1>first</i1> line.", null, null, null);
translateXML(filter, f);
}
Aggregations