Search in sources :

Example 1 with IAlignCallback

use of org.omegat.filters2.IAlignCallback 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)

Example 2 with IAlignCallback

use of org.omegat.filters2.IAlignCallback 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 3 with IAlignCallback

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

the class ILIASFilterTest method testAlign.

@Test
public void testAlign() throws Exception {
    final AlignResultHolder alignResult = new AlignResultHolder();
    align(new ILIASFilter(), "ilias/ILIASFilterAlign.lang", "ilias/ILIASFilterAlign-tr.lang", new IAlignCallback() {

        @Override
        public void addTranslation(String id, String source, String translation, boolean isFuzzy, String comment, IFilter filter) {
            alignResult.aligned = id.equals("module_name#:#variable_name") && source.equals("original") && translation.equals("translated");
        }
    });
    assertTrue(alignResult.aligned);
}
Also used : IFilter(org.omegat.filters2.IFilter) ILIASFilter(org.omegat.filters2.text.ilias.ILIASFilter) IAlignCallback(org.omegat.filters2.IAlignCallback) Test(org.junit.Test)

Example 4 with IAlignCallback

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

the class FilterMaster method alignFile.

public void alignFile(String sourceDir, String fileName, String targetdir, FilterContext fc, IAlignCallback alignCallback) throws Exception {
    LookupInformation lookup = lookupFilter(new File(sourceDir, fileName), fc);
    if (lookup == null) {
        // Skip it
        return;
    }
    File inFile = new File(sourceDir, fileName);
    File outFile = new File(targetdir, getTargetForSource(fileName, lookup, fc.getTargetLang()));
    if (!outFile.exists()) {
        // out file not exist - skip
        return;
    }
    fc.setInEncoding(lookup.outFilesInfo.getSourceEncoding());
    fc.setOutEncoding(lookup.outFilesInfo.getTargetEncoding());
    IFilter filterObject = lookup.filterObject;
    try {
        filterObject.alignFile(inFile, outFile, lookup.config, fc, alignCallback);
    } catch (Exception ex) {
        Log.log(ex);
    }
}
Also used : IFilter(org.omegat.filters2.IFilter) File(java.io.File) TranslationException(org.omegat.filters2.TranslationException) IOException(java.io.IOException)

Aggregations

IFilter (org.omegat.filters2.IFilter)4 Test (org.junit.Test)3 IAlignCallback (org.omegat.filters2.IAlignCallback)3 File (java.io.File)1 IOException (java.io.IOException)1 TranslationException (org.omegat.filters2.TranslationException)1 ResourceBundleFilter (org.omegat.filters2.text.bundles.ResourceBundleFilter)1 ILIASFilter (org.omegat.filters2.text.ilias.ILIASFilter)1 MagentoFilter (org.omegat.filters2.text.magento.MagentoFilter)1