Search in sources :

Example 1 with PoFilter

use of org.omegat.filters2.po.PoFilter in project omegat by omegat-org.

the class POFilterTest method testParse.

@Test
public void testParse() throws Exception {
    Map<String, String> data = new TreeMap<String, String>();
    Map<String, String> tmx = new TreeMap<String, String>();
    parse2(new PoFilter(), "test/data/filters/po/file-POFilter-be.po", data, tmx);
    assertEquals(data.get("non-fuzzy"), "non-fuzzy translation");
    assertEquals(tmx.get("[PO-fuzzy] fuzzy"), "fuzzy translation");
    assertEquals(tmx.get("[PO-fuzzy] Delete Account"), "Supprimer le compte");
    assertEquals(tmx.get("[PO-fuzzy] Delete Accounts"), "Supprimer des comptes");
}
Also used : PoFilter(org.omegat.filters2.po.PoFilter) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 2 with PoFilter

use of org.omegat.filters2.po.PoFilter in project omegat by omegat-org.

the class POFilterTest method testLoad.

@Test
public void testLoad() throws Exception {
    String f = "test/data/filters/po/file-POFilter-multiple.po";
    Map<String, String> options = new TreeMap<String, String>();
    options.put("skipHeader", "true");
    TestFileInfo fi = loadSourceFiles(new PoFilter(), f, options);
    String comment = OStrings.getString("POFILTER_TRANSLATOR_COMMENTS") + "\n" + "A valid comment\nAnother valid comment\n\n" + OStrings.getString("POFILTER_EXTRACTED_COMMENTS") + "\n" + "Some extracted comments\nMore extracted comments\n\n" + OStrings.getString("POFILTER_REFERENCES") + "\n" + "/my/source/file\n/my/source/file2\n\n";
    checkMultiStart(fi, f);
    checkMulti("source1", null, "some context", null, null, comment);
    checkMulti("source2", null, "", null, null, null);
    checkMulti("source3", null, "", null, null, null);
    checkMulti("source1", null, "", null, null, null);
    checkMulti("source1", null, "other context", null, null, null);
    checkMulti("source4", null, "one more context", null, null, null);
    checkMulti("source4", null, "one more context[1]", null, null, StringUtil.format(OStrings.getString("POFILTER_PLURAL_FORM_COMMENT"), 1) + "\n");
    checkMulti("source4", null, "one more context[2]", null, null, StringUtil.format(OStrings.getString("POFILTER_PLURAL_FORM_COMMENT"), 2) + "\n");
    checkMulti("source5", null, "", null, null, null);
    checkMulti("source6", null, "", null, null, null);
    checkMultiEnd();
    ExternalTMX tmEntries = fi.referenceEntries;
    assertEquals(2, tmEntries.getEntries().size());
    {
        PrepareTMXEntry entry = tmEntries.getEntries().get(0);
        assertEquals("True fuzzy!", entry.source);
        assertEquals("trans5", entry.translation);
    }
    {
        PrepareTMXEntry entry = tmEntries.getEntries().get(1);
        assertEquals("True fuzzy 2!", entry.source);
        assertEquals("trans6", entry.translation);
    }
}
Also used : PoFilter(org.omegat.filters2.po.PoFilter) ExternalTMX(org.omegat.core.data.ExternalTMX) TreeMap(java.util.TreeMap) PrepareTMXEntry(org.omegat.core.data.PrepareTMXEntry) Test(org.junit.Test)

Example 3 with PoFilter

use of org.omegat.filters2.po.PoFilter in project omegat by omegat-org.

the class POFilterTest method testLoadMonolingual.

@Test
public void testLoadMonolingual() throws Exception {
    String f = "test/data/filters/po/file-POFilter-Monolingual.po";
    PoFilter filter = new PoFilter();
    Map<String, String> options = new TreeMap<String, String>();
    options.put(PoFilter.OPTION_FORMAT_MONOLINGUAL, "true");
    List<ParsedEntry> parsed = parse3(filter, f, options);
    assertEquals(2, parsed.size());
    assertEquals("firstId", parsed.get(0).id);
    assertEquals("first source", parsed.get(0).source);
    assertEquals("secondId", parsed.get(1).id);
    assertEquals("second source", parsed.get(1).source);
}
Also used : PoFilter(org.omegat.filters2.po.PoFilter) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Aggregations

TreeMap (java.util.TreeMap)3 Test (org.junit.Test)3 PoFilter (org.omegat.filters2.po.PoFilter)3 ExternalTMX (org.omegat.core.data.ExternalTMX)1 PrepareTMXEntry (org.omegat.core.data.PrepareTMXEntry)1