Package org.zanata.rest.dto.extensions.gettext

Examples of org.zanata.rest.dto.extensions.gettext.PoTargetHeader


    public boolean transferFromTranslationsResourceExtensions(
            ExtensionSet<TranslationsResourceExtension> from, HDocument doc,
            Set<String> enabledExtensions, HLocale locale, MergeType mergeType) {
        boolean changed = false;
        if (enabledExtensions.contains(PoTargetHeader.ID)) {
            PoTargetHeader fromTargetHeader =
                    from.findByType(PoTargetHeader.class);
            if (fromTargetHeader != null) {
                log.debug("found PO header for locale: {}", locale);
                try {
                    changed =
View Full Code Here


            Set<String> enabledExtensions, HLocale locale,
            List<HTextFlowTarget> hTargets) {
        boolean found = false;
        if (enabledExtensions.contains(PoTargetHeader.ID)) {
            log.debug("PoTargetHeader requested");
            PoTargetHeader poTargetHeader = new PoTargetHeader();
            HPoTargetHeader fromHeader = from.getPoTargetHeaders().get(locale);
            if (fromHeader != null) {
                found = true;
                log.debug("PoTargetHeader found");
            } else {
View Full Code Here

        assertThat(changed, is(true));
    }

    @Test
    public void pushCommentInitialImport() {
        PoTargetHeader fromHeader = new PoTargetHeader();
        String comment = "comment to import\nsecond line";
        fromHeader.setComment(comment);
        HPoTargetHeader toHeader = new HPoTargetHeader();
        resourceUtils.pushPoTargetComment(fromHeader, toHeader, MergeType.AUTO);
        assertThat("", toHeader.getComment().getComment(), is(comment));
    }
View Full Code Here

        assertThat("", toHeader.getComment().getComment(), is(comment));
    }

    @Test
    public void pushCommentSkip() {
        PoTargetHeader fromHeader = new PoTargetHeader();
        String comment = "comment to import\nskip this #zanata\nlast line";
        String expectedComment = "comment to import\nlast line";
        fromHeader.setComment(comment);
        HPoTargetHeader toHeader = new HPoTargetHeader();
        resourceUtils.pushPoTargetComment(fromHeader, toHeader,
                MergeType.IMPORT);
        assertThat("", toHeader.getComment().getComment(), is(expectedComment));
    }
View Full Code Here

        assertThat("", toHeader.getComment().getComment(), is(expectedComment));
    }

    @Test
    public void pushCommentMerge() {
        PoTargetHeader fromHeader = new PoTargetHeader();
        String importedComment = "initial comment\nAlice #zanata\nCharlie";
        String expectedComment = "initial comment\nBob\nCharlie";
        fromHeader.setComment(importedComment);
        HPoTargetHeader toHeader = new HPoTargetHeader();
        toHeader.setComment(new HSimpleComment("initial comment\nBob"));
        resourceUtils.pushPoTargetComment(fromHeader, toHeader, MergeType.AUTO);
        assertThat("", toHeader.getComment().getComment(), is(expectedComment));
    }
View Full Code Here

        assertThat("", toHeader.getComment().getComment(), is(expectedComment));
    }

    @Test
    public void pushCommentImport() {
        PoTargetHeader fromHeader = new PoTargetHeader();
        String importedComment = "initial comment\nAlice #zanata\nCharlie";
        String expectedComment = "initial comment\nCharlie";
        fromHeader.setComment(importedComment);
        HPoTargetHeader toHeader = new HPoTargetHeader();
        toHeader.setComment(new HSimpleComment("initial comment\nBob"));
        resourceUtils.pushPoTargetComment(fromHeader, toHeader,
                MergeType.IMPORT);
        assertThat("", toHeader.getComment().getComment(), is(expectedComment));
View Full Code Here

    @Test
    public void pullCommentEmpty() {

        HPoTargetHeader fromHeader = new HPoTargetHeader();
        PoTargetHeader toHeader = new PoTargetHeader();

        List<HTextFlowTarget> hTargets = Collections.emptyList();
        resourceUtils.pullPoTargetComment(fromHeader, toHeader, hTargets);

        assertThat("", toHeader.getComment(), is(""));
    }
View Full Code Here

    public void pullCommentInitial() {

        HPoTargetHeader fromHeader = new HPoTargetHeader();
        fromHeader.setComment(new HSimpleComment("initial comment"));
        String expectedComment = "initial comment";
        PoTargetHeader toHeader = new PoTargetHeader();

        List<HTextFlowTarget> hTargets = Collections.emptyList();
        resourceUtils.pullPoTargetComment(fromHeader, toHeader, hTargets);

        assertThat("", toHeader.getComment(), is(expectedComment));
    }
View Full Code Here

        fromHeader.setComment(new HSimpleComment("initial comment"));
        String expectedComment =
                "initial comment\n"
                        + "Alice <alice@example.org>, 2010. #zanata\n"
                        + "Alice <alice@example.org>, 2011. #zanata";
        PoTargetHeader toHeader = new PoTargetHeader();

        HPerson alice = new HPerson();
        alice.setName("Alice");
        alice.setEmail("alice@example.org");
        List<HTextFlowTarget> hTargets = new ArrayList<HTextFlowTarget>();
        HTextFlowTarget tft1 = new HTextFlowTarget();
        tft1.setLastChanged(new Date(1302671654000L)); // 13 Apr 2011
        tft1.setLastModifiedBy(alice);
        hTargets.add(tft1);

        HTextFlowTarget tft2 = new HTextFlowTarget();
        tft2.setLastChanged(new Date(1304329523000L)); // 2 May 2011
        tft2.setLastModifiedBy(alice);
        hTargets.add(tft2);

        HTextFlowTarget tft3 = new HTextFlowTarget();
        tft3.setLastChanged(new Date(1262419384000L)); // 2 Jan 2010
        tft3.setLastModifiedBy(alice);
        hTargets.add(tft3);

        resourceUtils.pullPoTargetComment(fromHeader, toHeader, hTargets);

        assertThat("", toHeader.getComment(), is(expectedComment));
    }
View Full Code Here

        return sr;
    }

    public TranslationsResource getPoTargetHeaderTextFlowTargetTest() {
        TranslationsResource sr = getTestObject();
        PoTargetHeader poTargetHeader =
                new PoTargetHeader(
                        "target header comment\nAdmin user <root@localhost>, 2011. #zanata",
                        new HeaderEntry("ht", "vt1"), new HeaderEntry("th2",
                                "tv2"), new HeaderEntry("Content-Type",
                                "charset=UTF-8"));
View Full Code Here

TOP

Related Classes of org.zanata.rest.dto.extensions.gettext.PoTargetHeader

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.