Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
convert okapi inline codes to and from generic tags
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Aug 31, 2012
1 parent aa0b781 commit 9a01811
Showing 1 changed file with 8 additions and 4 deletions.
Expand Up @@ -32,10 +32,10 @@
import net.sf.okapi.common.EventType;
import net.sf.okapi.common.exceptions.OkapiIOException;
import net.sf.okapi.common.filters.IFilter;
import net.sf.okapi.common.filterwriter.GenericContent;
import net.sf.okapi.common.filterwriter.IFilterWriter;
import net.sf.okapi.common.resource.RawDocument;
import net.sf.okapi.common.resource.StartSubDocument;
import net.sf.okapi.common.resource.TextFragment;
import net.sf.okapi.common.resource.TextUnit;

import org.slf4j.Logger;
Expand Down Expand Up @@ -74,6 +74,8 @@ public enum IdSource {
private final IdSource idSource;
private boolean requireFileOutput;

private final GenericContent converter;

/**
* Create an adapter that will use filter-provided id as TextFlow id.
*
Expand Down Expand Up @@ -107,6 +109,8 @@ public GenericOkapiFilterAdapter(IFilter filter, IdSource idSource, boolean requ
this.idSource = idSource;
this.requireFileOutput = requireFileOutput;

this.converter = new GenericContent();

log = LoggerFactory.getLogger(GenericOkapiFilterAdapter.class);
}

Expand Down Expand Up @@ -145,7 +149,7 @@ else if (event.getEventType() == EventType.TEXT_UNIT)
{
TextFlow tf = new TextFlow(getIdFor(tu, subDocName), sourceLocale);
tf.setPlural(false);
tf.setContents(tu.getSource().toString());
tf.setContents(converter.fromFragmentToLetterCoded(tu.getSource().getFirstContent()));
resources.add(tf);
}
}
Expand Down Expand Up @@ -208,7 +212,7 @@ else if (event.getEventType() == EventType.TEXT_UNIT)
if (tu.isTranslatable())
{
TextFlowTarget tft = new TextFlowTarget(getIdFor(tu, subDocName));
tft.setContents(tu.getSource().toString());
tft.setContents(converter.fromFragmentToLetterCoded(tu.getSource().getFirstContent()));
tft.setState(ContentState.Approved);
translations.add(tft);
}
Expand Down Expand Up @@ -307,7 +311,7 @@ else if (event.getEventType() == EventType.TEXT_UNIT)
TextFlowTarget tft = translations.get(getIdFor(tu, subDocName));
if (tft != null)
{
tu.setTargetContent(localeId, new TextFragment(tft.getContents().get(0)));
tu.setTargetContent(localeId, converter.fromLetterCodedToFragment(tft.getContents().get(0), tu.getSource().getFirstContent().clone(), true));
}
}
writer.handleEvent(event);
Expand Down

0 comments on commit 9a01811

Please sign in to comment.