Search in sources :

Example 6 with IFilter

use of org.omegat.filters2.IFilter in project omegat by omegat-org.

the class FilterEditor method editButtonActionPerformed.

// GEN-LAST:event_addButtonActionPerformed
private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_editButtonActionPerformed
    int row = instances.getSelectedRow();
    IFilter f = FilterMaster.getFilterInstance(filter.getClassName());
    if (f == null) {
        return;
    }
    InstanceEditor ie = new InstanceEditor(this, f.isSourceEncodingVariable(), f.isTargetEncodingVariable(), f.getHint(), instances.getModel().getValueAt(row, 0).toString(), instances.getModel().getValueAt(row, 1).toString(), instances.getModel().getValueAt(row, 2).toString(), instances.getModel().getValueAt(row, 3).toString());
    ie.setVisible(true);
    if (ie.getReturnStatus() == InstanceEditor.RET_OK) {
        Files ff = new Files();
        ff.setSourceEncoding(setEncodingName(ie.getSourceEncoding()));
        ff.setSourceFilenameMask(ie.getSourceFilenameMask());
        ff.setTargetEncoding(setEncodingName(ie.getTargetEncoding()));
        ff.setTargetFilenamePattern(ie.getTargetFilenamePattern());
        filter.getFiles().set(row, ff);
        instances.setModel(new OneFilterTableModel(filter));
    }
}
Also used : IFilter(org.omegat.filters2.IFilter) OneFilterTableModel(org.omegat.filters2.master.OneFilterTableModel) Files(gen.core.filters.Files)

Example 7 with IFilter

use of org.omegat.filters2.IFilter in project omegat by omegat-org.

the class TmxComplianceBase method translateUsingTmx.

protected void translateUsingTmx(IFilter filter, Map<String, String> config, final String fileTextIn, String inCharset, String fileTMX, String outCharset, ProjectProperties props, Map<String, TMXEntry> tmxPatch) throws Exception {
    final ProjectTMX tmx = new ProjectTMX(props.getSourceLanguage(), props.getTargetLanguage(), props.isSentenceSegmentingEnabled(), new File("test/data/tmx/TMXComplianceKit/" + fileTMX), orphanedCallback);
    if (tmxPatch != null) {
        tmx.defaults.putAll(tmxPatch);
    }
    FilterContext fc = new FilterContext(props);
    fc.setInEncoding(inCharset);
    fc.setOutEncoding(outCharset);
    ITranslateCallback cb = new TranslateEntry(props) {

        @Override
        protected String getSegmentTranslation(String id, int segmentIndex, String segmentSource, String prevSegment, String nextSegment, String path) {
            TMXEntry e = tmx.getDefaultTranslation(segmentSource);
            assertNotNull(e);
            return e.translation;
        }

        @Override
        String getCurrentFile() {
            return fileTextIn;
        }
    };
    filter.translateFile(new File("test/data/tmx/TMXComplianceKit/" + fileTextIn), outFile, config, fc, cb);
}
Also used : ITranslateCallback(org.omegat.filters2.ITranslateCallback) File(java.io.File) FilterContext(org.omegat.filters2.FilterContext)

Example 8 with IFilter

use of org.omegat.filters2.IFilter in project omegat by omegat-org.

the class MoodlePHPFilterTest method testAlign.

@Test
public void testAlign() throws Exception {
    final AlignResult ar = new AlignResult();
    align(new MoodlePHPFilter(), "MoodlePHP/filesAlign.php", "MoodlePHP/filesAlign_gl.php", new IAlignCallback() {

        public void addTranslation(String id, String source, String translation, boolean isFuzzy, String path, IFilter filter) {
            ar.found = id.equals("access") && source.equals("Accessibility") && translation.equals("Accesibilidade");
        }
    });
    assertTrue(ar.found);
}
Also used : IFilter(org.omegat.filters2.IFilter) MoodlePHPFilter(org.omegat.filters2.moodlephp.MoodlePHPFilter) IAlignCallback(org.omegat.filters2.IAlignCallback) Test(org.junit.Test)

Example 9 with IFilter

use of org.omegat.filters2.IFilter in project omegat by omegat-org.

the class ResourceBundleFilterTest method testAlign.

@Test
public void testAlign() throws Exception {
    final AlignResult ar = new AlignResult();
    align(new ResourceBundleFilter(), "resourceBundle/file-ResourceBundleFilter.properties", "resourceBundle/file-ResourceBundleFilter_be.properties", new IAlignCallback() {

        public void addTranslation(String id, String source, String translation, boolean isFuzzy, String path, IFilter filter) {
            ar.found = id.equals("ID") && source.equals("Value") && translation.equals("test");
        }
    });
    assertTrue(ar.found);
}
Also used : IFilter(org.omegat.filters2.IFilter) ResourceBundleFilter(org.omegat.filters2.text.bundles.ResourceBundleFilter) IAlignCallback(org.omegat.filters2.IAlignCallback) Test(org.junit.Test)

Example 10 with IFilter

use of org.omegat.filters2.IFilter in project omegat by omegat-org.

the class MagentoFilterTest method testAlign.

@Test
public void testAlign() throws Exception {
    final AlignResultHolder alignResult = new AlignResultHolder();
    align(new MagentoFilter(), "magento/MagentoFilterAlign.csv", "magento/MagentoFilterAlign-tr.csv", new IAlignCallback() {

        public void addTranslation(String id, String source, String translation, boolean isFuzzy, String comment, IFilter filter) {
            alignResult.aligned = id.equals("code") && source.equals("original") && translation.equals("translated");
        }
    });
    assertTrue(alignResult.aligned);
}
Also used : IFilter(org.omegat.filters2.IFilter) MagentoFilter(org.omegat.filters2.text.magento.MagentoFilter) IAlignCallback(org.omegat.filters2.IAlignCallback) Test(org.junit.Test)

Aggregations

IFilter (org.omegat.filters2.IFilter)19 File (java.io.File)8 Files (gen.core.filters.Files)5 ArrayList (java.util.ArrayList)5 FilterContext (org.omegat.filters2.FilterContext)5 IParseCallback (org.omegat.filters2.IParseCallback)5 Filter (gen.core.filters.Filter)4 Test (org.junit.Test)4 ProtectedPart (org.omegat.core.data.ProtectedPart)4 IAlignCallback (org.omegat.filters2.IAlignCallback)4 IOException (java.io.IOException)3 AbstractFilter (org.omegat.filters2.AbstractFilter)3 TranslationException (org.omegat.filters2.TranslationException)3 OneFilterTableModel (org.omegat.filters2.master.OneFilterTableModel)2 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 RandomAccessFile (java.io.RandomAccessFile)1 List (java.util.List)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1