@Test public void testAlignment() throws Exception { XLIFFTargetContentAligner aligner = new XLIFFTargetContentAligner(WSTranslationType.MANUAL_TRANSLATION); List<WSTextSegmentTranslation> translation = new ArrayList<>(); translation.add(t("Hello", "", new String[0], new String[0])); translation.add(t("Goodbye {1}my friends{2}.", "", new String[] {"<g id=\"1\">", "</g>"}, new String[0])); try (InputStream is = getClass().getResourceAsStream("/test.xlf")) { int count = aligner.alignTargetContent(is, "UTF-8", LocaleId.ENGLISH, translation.iterator()); assertEquals(2, count); assertEquals("Bonjour", translation.get(0).getTarget()); assertEquals("Au revoir {1}mes amis{2}.", translation.get(1).getTarget()); assertEquals(WSTranslationType.MANUAL_TRANSLATION, translation.get(0).getTranslationType()); assertEquals(WSTranslationType.MANUAL_TRANSLATION, translation.get(1).getTranslationType()); } }
public int alignTargetContent(InputStream xliffStream, String encoding, LocaleId srcLocale, Iterator<WSTextSegmentTranslation> textSegs) throws IOException { List<ITextUnit> xliffTus = getEvents(xliffStream, encoding, srcLocale); int count = 0; for (ITextUnit xliffTu : xliffTus) { TextContainer sourceTc = xliffTu.getSource(); TextContainer targetTc = findFirstTarget(xliffTu); if (targetTc == null) { for (@SuppressWarnings("unused") Segment seg : sourceTc.getSegments()) { skipSegment(textSegs); } continue; } for (Segment seg : targetTc.getSegments()) { boolean injected = injectNextSegment(seg, textSegs); if (injected) { count++; } } } return count; }
XLIFFTargetContentAligner { public int alignTargetContent(InputStream xliffStream, String encoding, LocaleId srcLocale, Iterator<WSTextSegmentTranslation> textSegs) throws IOException { List<ITextUnit> xliffTus = getEvents(xliffStream, encoding, srcLocale); int count = 0; for (ITextUnit xliffTu : xliffTus) { TextContainer sourceTc = xliffTu.getSource(); TextContainer targetTc = findFirstTarget(xliffTu); if (targetTc == null) { for (@SuppressWarnings("unused") Segment seg : sourceTc.getSegments()) { skipSegment(textSegs); } continue; } for (Segment seg : targetTc.getSegments()) { boolean injected = injectNextSegment(seg, textSegs); if (injected) { count++; } } } return count; } }
XLIFFTargetContentAligner { public int alignTargetContent(InputStream xliffStream, String encoding, LocaleId srcLocale, Iterator<WSTextSegmentTranslation> textSegs) throws IOException { List<ITextUnit> xliffTus = getEvents(xliffStream, encoding, srcLocale); int count = 0; for (ITextUnit xliffTu : xliffTus) { TextContainer sourceTc = xliffTu.getSource(); TextContainer targetTc = findFirstTarget(xliffTu); if (targetTc == null) { for (@SuppressWarnings("unused") Segment seg : sourceTc.getSegments()) { skipSegment(textSegs); } continue; } for (Segment seg : targetTc.getSegments()) { boolean injected = injectNextSegment(seg, textSegs); if (injected) { count++; } } } return count; } XLIFFTargetContentAligner(WSTranslationType injectedTranslationType); }
XLIFFTargetContentAligner { public int alignTargetContent(InputStream xliffStream, String encoding, LocaleId srcLocale, Iterator<WSTextSegmentTranslation> textSegs) throws IOException { List<ITextUnit> xliffTus = getEvents(xliffStream, encoding, srcLocale); int count = 0; for (ITextUnit xliffTu : xliffTus) { TextContainer sourceTc = xliffTu.getSource(); TextContainer targetTc = findFirstTarget(xliffTu); if (targetTc == null) { for (@SuppressWarnings("unused") Segment seg : sourceTc.getSegments()) { skipSegment(textSegs); } continue; } for (Segment seg : targetTc.getSegments()) { boolean injected = injectNextSegment(seg, textSegs); if (injected) { count++; } } } return count; } XLIFFTargetContentAligner(WSTranslationType injectedTranslationType); int alignTargetContent(InputStream xliffStream, String encoding, LocaleId srcLocale,
                                  Iterator<WSTextSegmentTranslation> textSegs); }
XLIFFTargetContentAligner { public int alignTargetContent(InputStream xliffStream, String encoding, LocaleId srcLocale, Iterator<WSTextSegmentTranslation> textSegs) throws IOException { List<ITextUnit> xliffTus = getEvents(xliffStream, encoding, srcLocale); int count = 0; for (ITextUnit xliffTu : xliffTus) { TextContainer sourceTc = xliffTu.getSource(); TextContainer targetTc = findFirstTarget(xliffTu); if (targetTc == null) { for (@SuppressWarnings("unused") Segment seg : sourceTc.getSegments()) { skipSegment(textSegs); } continue; } for (Segment seg : targetTc.getSegments()) { boolean injected = injectNextSegment(seg, textSegs); if (injected) { count++; } } } return count; } XLIFFTargetContentAligner(WSTranslationType injectedTranslationType); int alignTargetContent(InputStream xliffStream, String encoding, LocaleId srcLocale,
                                  Iterator<WSTextSegmentTranslation> textSegs);  }