當前位置: 首頁>>代碼示例>>Java>>正文


Java XLIFFFilter類代碼示例

本文整理匯總了Java中net.sf.okapi.filters.xliff.XLIFFFilter的典型用法代碼示例。如果您正苦於以下問題:Java XLIFFFilter類的具體用法?Java XLIFFFilter怎麽用?Java XLIFFFilter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XLIFFFilter類屬於net.sf.okapi.filters.xliff包,在下文中一共展示了XLIFFFilter類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: importXLIFF

import net.sf.okapi.filters.xliff.XLIFFFilter; //導入依賴的package包/類
@Transactional
private void importXLIFF(ImportExportedXliffStep importExportedXliffStep, String xliffContent) {

    IPipelineDriver driver = new PipelineDriver();
    XLIFFFilter xliffFilter = new XLIFFFilter();
    driver.addStep(new RawDocumentToFilterEventsStep(xliffFilter));

    importExportedXliffStep.setXliffFilter(xliffFilter);
    driver.addStep(importExportedXliffStep);

    RawDocument rawDocument = new RawDocument(xliffContent, LocaleId.ENGLISH);

    driver.addBatchItem(rawDocument);

    logger.debug("Start importing XLIFF");
    driver.processBatch();
}
 
開發者ID:box,項目名稱:mojito,代碼行數:18,代碼來源:TMImportService.java

示例2: updateTMWithXliff

import net.sf.okapi.filters.xliff.XLIFFFilter; //導入依賴的package包/類
/**
 * Update TM with XLIFF.
 *
 * @param xliffContent The content of the localized XLIFF TODO(P1) Use BCP47
 * tag instead of Locale object?
 * @param importStatus specific status to use when importing translation
 * @param abstractImportTranslationsStep defines which import logic to apply
 * @return the imported XLIFF with information for each text unit about the
 * import process
 * @throws OkapiBadFilterInputException
 */
private UpdateTMWithXLIFFResult updateTMWithXliff(
        String xliffContent,
        TMTextUnitVariant.Status importStatus,
        AbstractImportTranslationsStep abstractImportTranslationsStep) throws OkapiBadFilterInputException {

    logger.debug("Configuring pipeline for localized XLIFF processing");

    IPipelineDriver driver = new PipelineDriver();
    driver.addStep(new RawDocumentToFilterEventsStep(new XLIFFFilter()));

    driver.addStep(getConfiguredQualityStep());
    IntegrityCheckStep integrityCheckStep = new IntegrityCheckStep();
    driver.addStep(integrityCheckStep);

    abstractImportTranslationsStep.setImportWithStatus(importStatus);
    driver.addStep(abstractImportTranslationsStep);

    //TODO(P1) It sounds like it's not possible to the XLIFFFilter for the output
    // because the note is readonly mode and we need to override it to provide more information
    logger.debug("Prepare FilterEventsWriterStep to use an XLIFFWriter with outputstream (allows only one doc to be processed)");
    FilterEventsWriterStep filterEventsWriterStep = new FilterEventsWriterStep(new XLIFFWriter());
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    filterEventsWriterStep.setOutputStream(byteArrayOutputStream);
    filterEventsWriterStep.setOutputEncoding(StandardCharsets.UTF_8.toString());

    driver.addStep(filterEventsWriterStep);

    // We need to read first the target language, because if we wait for okapi to read
    // it from the file it is too late to write the output with the XLIFFWriter 
    // (missing target language)
    String targetLanguage = xliffUtils.getTargetLanguage(xliffContent);
    LocaleId targetLocaleId = targetLanguage != null ? LocaleId.fromBCP47(targetLanguage) : LocaleId.EMPTY;
    RawDocument rawDocument = new RawDocument(xliffContent, LocaleId.ENGLISH, targetLocaleId);

    driver.addBatchItem(rawDocument, RawDocument.getFakeOutputURIForStream(), null);

    logger.debug("Start processing batch");
    driver.processBatch();

    logger.debug("Get the Import report");
    ImportTranslationsStepAnnotation importTranslationsStepAnnotation = rawDocument.getAnnotation(ImportTranslationsStepAnnotation.class);

    UpdateTMWithXLIFFResult updateReport = new UpdateTMWithXLIFFResult();
    updateReport.setXliffContent(StreamUtil.getUTF8OutputStreamAsString(byteArrayOutputStream));
    updateReport.setComment(importTranslationsStepAnnotation.getComment());

    return updateReport;
}
 
開發者ID:box,項目名稱:mojito,代碼行數:60,代碼來源:TMService.java

示例3: setXliffFilter

import net.sf.okapi.filters.xliff.XLIFFFilter; //導入依賴的package包/類
public void setXliffFilter(XLIFFFilter xliffFilter) {
    this.xliffFilter = xliffFilter;
}
 
開發者ID:box,項目名稱:mojito,代碼行數:4,代碼來源:ImportExportedXliffStep.java

示例4: testXLIFFFilterConfigIdConstMatchesOkapiConfigId

import net.sf.okapi.filters.xliff.XLIFFFilter; //導入依賴的package包/類
@Test
public void testXLIFFFilterConfigIdConstMatchesOkapiConfigId() throws Exception {

    String okapiConfigId = new XLIFFFilter().getName();
    assertEquals(AssetPathToFilterConfigMapper.XLIFF_FILTER_CONFIG_ID, okapiConfigId);
}
 
開發者ID:box,項目名稱:mojito,代碼行數:7,代碼來源:AssetPathToFilterConfigMapperTest.java


注:本文中的net.sf.okapi.filters.xliff.XLIFFFilter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。