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));
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations