Package org.zanata.model.tm

Examples of org.zanata.model.tm.TransMemoryUnitVariant


            return tu.getTransUnitId();
        } else {
            // Go looking for a source content hash
            String srcLang = tu.getSourceLanguage();
            if (srcLang != null) {
                TransMemoryUnitVariant sourceVariant =
                        tu.getTransUnitVariants().get(srcLang);
                if (sourceVariant == null) {
                    throw new TMXParseException(
                            "Source variant cannot be determined for Translation unit with no tuid.");
                }
                return sourceVariant.getPlainTextSegmentHash();
            } else {
                throw new TMXParseException(
                        "Source language cannot be determined for Translation unit with no tuid. "
                                + "It must be defined either in the <tu> or the <header> element.");
            }
View Full Code Here


    private void addVariant(TransMemoryUnit tu, Element tuvElem)
            throws TMXParseException {
        String taggedSegment = tuvElem.getFirstChildElement("seg").toXML();

        TransMemoryUnitVariant tuv = new TransMemoryUnitVariant();
        tuv.setTaggedSegment(taggedSegment);
        TMXMetadataHelper.setMetadata(tuv, tuvElem);
        tu.getTransUnitVariants().put(tuv.getLanguage(), tuv);
    }
View Full Code Here

            localeId = tf.getDocument().getLocale().getLocaleId();
        } else if (entity instanceof HTextFlowTarget) {
            HTextFlowTarget tft = (HTextFlowTarget) entity;
            localeId = tft.getLocale().getLocaleId();
        } else if (entity instanceof TransMemoryUnitVariant) {
            TransMemoryUnitVariant tuv = (TransMemoryUnitVariant) entity;
            localeId = new LocaleId(tuv.getLanguage());
        } else {
            throw new IllegalArgumentException("Illegal text container type: "
                    + entity.getClass().getName());
        }
View Full Code Here

*/
public class TransUnitVariantClassBridge implements FieldBridge {
    @Override
    public void set(String s, Object value, Document document,
            LuceneOptions luceneOptions) {
        TransMemoryUnitVariant variant = (TransMemoryUnitVariant) value;

        String textToIndex = variant.getPlainTextSegment();
        Field field =
                new Field(IndexFieldLabels.TRANS_UNIT_VARIANT_FIELD
                        + variant.getLanguage(), textToIndex,
                        luceneOptions.getStore(), luceneOptions.getIndex(),
                        luceneOptions.getTermVector());
        field.setBoost(luceneOptions.getBoost());
        document.add(field);
    }
View Full Code Here

        assertThat(tu1Children.get(2).getValue(), is("Custom note0"));
        assertThat(tu1Children.get(3).getLocalName(), is("note"));
        assertThat(tu1Children.get(3).getValue(), is("Custom note1"));

        // Metadata at the TUV level
        TransMemoryUnitVariant tuv0 = tu0.getTransUnitVariants().get("en");
        Map<String, String> tuv0Atts = TMXMetadataHelper.getAttributes(tuv0);
        assertThat(tuv0Atts.size(), is(3));
        assertThat(tuv0Atts, hasEntry("xml:lang", "en"));
        assertThat(tuv0Atts, hasKey("creationdate"));
        assertThat(tuv0Atts, hasKey("changedate"));
View Full Code Here

        // Fetch the translation memory
        TransMemory stored = loadTM("new-trans-memory");

        // For each trans unit, generate some variants
        for (TransMemoryUnit tu : stored.getTranslationUnits()) {
            TransMemoryUnitVariant tuvES =
                    new TransMemoryUnitVariant("es",
                            "<seg>Mensaje de Prueba</seg>");
            TransMemoryUnitVariant tuvEN =
                    new TransMemoryUnitVariant("en-US",
                            "<seg>Test Message</seg>");
            TransMemoryUnitVariant tuvFR =
                    new TransMemoryUnitVariant("fr",
                            "<seg>Message de test</seg>");

            tu.getTransUnitVariants().put(tuvES.getLanguage(), tuvES);
            tu.getTransUnitVariants().put(tuvEN.getLanguage(), tuvEN);
            tu.getTransUnitVariants().put(tuvFR.getLanguage(), tuvFR);

            super.getEm().merge(tu);
        }

        // Verify they were saved
View Full Code Here

        // Fetch the translation memory
        TransMemory stored = loadTM("new-trans-memory");

        // Store a Trans unit variant with formatting
        TransMemoryUnit tu = stored.getTranslationUnits().iterator().next();
        TransMemoryUnitVariant tuvES =
                new TransMemoryUnitVariant("es",
                        "<seg>Mensaje <bpt>&lt;b></bpt>de<ept i=\"1\">&lt;b></ept> Prueba</seg>");

        tu.getTransUnitVariants().put(tuvES.getLanguage(), tuvES);

        super.getEm().merge(tu);

        // Verify they were saved
        TransMemoryUnitVariant tuv =
                (TransMemoryUnitVariant) queryTUVs().getSingleResult();
        assertThat(tuv.getPlainTextSegment(), equalTo("Mensaje de Prueba"));
    }
View Full Code Here

TOP

Related Classes of org.zanata.model.tm.TransMemoryUnitVariant

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.