コード例 #1
0
  public void extractTranslatedFilesFromXliffs() {

    IPipelineDriver driverX = new PipelineDriver();
    driverX.setFilterConfigurationMapper(fcMapper);

    // L10nFile file = files.get(0);
    // LocaleId locale = LocaleId.FRENCH;

    for (L10nFile file : project.getFiles()) {
      for (LocaleId locale : project.getTargetLocales()) {

        // represents source document (e.g. file.resx)
        RawDocument originalDoc =
            new RawDocument(
                new File(file.getLocalPath()).toURI(),
                file.getEncoding(),
                project.sourceLocale,
                locale);
        originalDoc.setFilterConfigId(file.getFilterConfigurationId());

        // reprosents translated xliff file
        RawDocument xliffDoc =
            new RawDocument(
                new File(file.getLocalXliffPath_SourceWithLocaleCodeBeforeXliffExtension(locale))
                    .toURI(),
                "UTF-8",
                project.sourceLocale,
                locale);

        BatchItemContext bic =
            new BatchItemContext(
                xliffDoc,
                Util.toURI(file.getLocalPath(locale)),
                file.getEncoding(locale),
                originalDoc);
        driverX.addBatchItem(bic);
      }
    }

    driverX.addStep(new OriginalDocumentXliffMergerStep());
    driverX.addStep(new RawDocumentWriterStep());

    project.getEventCannon().fireEvent(CtsAppEventType.ExtractingFromXliffStarted);
    driverX.processBatch();
    project.getEventCannon().fireEvent(CtsAppEventType.ExtractingFromXliffFinished);

    driverX.destroy();
  }
コード例 #2
0
  @Test
  public void testSimpleStep() throws URISyntaxException {
    IPipelineDriver pdriver = new PipelineDriver();
    pdriver.setRootDirectories(
        Util.deleteLastChar(root), Util.deleteLastChar(root)); // Don't include final separator
    pdriver.addStep(new RawDocumentToFilterEventsStep());
    pdriver.addStep(new FileAnalysisStep());

    URI inputURI = new File(root + "/test01.properties").toURI();
    RawDocument rd = new RawDocument(inputURI, "UTF-8", locEN);
    pdriver.addBatchItem(new BatchItemContext(rd, null, null));

    pdriver.processBatch();

    // TODO: test results
  }