Beispiel #1
0
  public void submitTranslatedFiles() {
    project.getEventCannon().fireEvent(CtsAppEventType.SubmitStarted);

    SyncerCommandLineAppService syncer = new SyncerCommandLineAppService(project);
    syncer.UploadFiles();

    project.getEventCannon().fireEvent(CtsAppEventType.SubmitFinished);
  }
Beispiel #2
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();
  }
Beispiel #3
0
  /** translates the project xliff files using the set Translation Service Provider */
  public void translateXliffs() {
    project.getEventCannon().fireEvent(CtsAppEventType.TranslationStarted);

    // this is needed for the files to be leveraged when uploaded in crowdin (if original attribute
    // is different xliff files are not leveraged)
    // Helper.transformOriginalAttributeInSourceXliffFiles(project);
    // Helper.prepXliffsForCrowdIn(project); //todo: this should be moved to crowdin implementation
    // of translatexliffs()

    project.getTranslationServiceAgent().TranslateXliffs();

    // Helper.prepXliffsAfterCrowdIn(project); //todo: this should be moved to crowdin
    // implementation of translatexliffs()

    project.getEventCannon().fireEvent(CtsAppEventType.TranslationFinished);
  }
Beispiel #4
0
  private void addRawDocumentsIntoPipeline(LocaleId locale) {
    String.format("adding RawDocuments (locale: [%s]) to pipeline", locale);

    for (L10nFile f : project.getFiles()) {

      RawDocument rd = null;
      if (!project.createTM) {
        rd = new RawDocument(f.getURI(), f.getEncoding(), project.sourceLocale, locale);
      } else {
        rd = new RawDocument(f.getURI(locale), f.getEncoding(locale), locale, locale);
      }
      rd.setFilterConfigId(f.getFilterConfigurationId());

      URI targetUri;
      if (!project.createTM) targetUri = new File(f.getLocalXliffPath(locale)).toURI();
      else {
        targetUri =
            new File(f.getLocalXliffPath_SourceWithLocaleCodeBeforeXliffExtension(locale)).toURI();
      }

      driver.addBatchItem(rd, targetUri, f.getEncoding(locale));

      projetLogger.debug(
          String.format(
              "[%s] added to the pipeline driver (target uri: [%s])",
              f.getURI(), targetUri.toString()));
    }
  }
Beispiel #5
0
  public void ExecuteSyncFlow() {
    // if set to true - creates xliff files, mainly for creating xliffs to
    // process via crowndin (also good if testing new filters)
    // if set to false creates output files in source format

    initializePipeLine();

    // if (createXliffs) {
    if (!project.createTM) {
      addRawDocumentsIntoPipeline(
          project.sourceLocale); // adds xliffs as output documents (file.en.xliff)
    } else {
      addRawDocumentsIntoPipeline(project.getAllLocales());

      // addRawDocumentsIntoPipeline(project.getTargetLocales(), createXliffs); // adds source
      // format files as output documents
    }

    addSyncStep();
    addRawDocumentToFilterEventStep();
    // addPseudoLocalizationStep();

    addSaveXliffStep(); // this step will create xliff files (output
    // URIs must have been xliffs)
    // addTextUnit2DBStep();

    processSyncFlowPipeline();
  }
Beispiel #6
0
  public CtsApp(CtsProject ctsProject, CtsAppData configurationData) {

    project = ctsProject;
    configData = configurationData;

    // when creating tm always use either Sync (if set) or SyncTranslate
    if (project.createTM) {
      if (project.getCtsWorkFlow() == CtsWorkFlow.SyncTranslateSubmit) {
        project.setCtsWorkFlow(CtsWorkFlow.SyncTranslate);
        projetLogger.debug("setting workflow to: \n{} \n\n", project.getCtsWorkFlow());
      }
    }

    projetLogger.info("CtsConsole was started for {}", project.getId());
    projetLogger.debug("project.toString(): \n{} \n\n", project.toString());

    // project.getEventCannon().addCtsAppEventsListener(new DefaultCtsAppEventHandler());
    project.getEventCannon().fireEvent(CtsAppEventType.CtsAppStarted);
  }