Search in sources :

Example 26 with Language

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));
}
Also used : Language(org.omegat.util.Language) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 27 with Language

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);
}
Also used : Language(org.omegat.util.Language) ArrayList(java.util.ArrayList)

Example 28 with Language

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);
}
Also used : Language(org.omegat.util.Language) HTMLFilter2(org.omegat.filters2.html2.HTMLFilter2) File(java.io.File) IProject(org.omegat.core.data.IProject) FilterContext(org.omegat.filters2.FilterContext) Test(org.junit.Test)

Example 29 with Language

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);
}
Also used : XHTMLFilter(org.omegat.filters3.xml.xhtml.XHTMLFilter) Language(org.omegat.util.Language) File(java.io.File) IProject(org.omegat.core.data.IProject) FilterContext(org.omegat.filters2.FilterContext) Test(org.junit.Test)

Example 30 with Language

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);
}
Also used : XHTMLFilter(org.omegat.filters3.xml.xhtml.XHTMLFilter) Language(org.omegat.util.Language) File(java.io.File) IProject(org.omegat.core.data.IProject) FilterContext(org.omegat.filters2.FilterContext) Test(org.junit.Test)

Aggregations

Language (org.omegat.util.Language)43 Test (org.junit.Test)16 File (java.io.File)13 ArrayList (java.util.ArrayList)13 Map (java.util.Map)7 FilterContext (org.omegat.filters2.FilterContext)7 List (java.util.List)6 IProject (org.omegat.core.data.IProject)6 SourceTextEntry (org.omegat.core.data.SourceTextEntry)5 HashMap (java.util.HashMap)4 Before (org.junit.Before)4 EntryKey (org.omegat.core.data.EntryKey)4 ProjectTMX (org.omegat.core.data.ProjectTMX)4 TMXEntry (org.omegat.core.data.TMXEntry)4 XHTMLFilter (org.omegat.filters3.xml.xhtml.XHTMLFilter)4 DefaultTokenizer (org.omegat.tokenizer.DefaultTokenizer)4 ITokenizer (org.omegat.tokenizer.ITokenizer)4 IOException (java.io.IOException)3 Files (java.nio.file.Files)3 Matcher (java.util.regex.Matcher)3