Package org.zanata.model.po

Examples of org.zanata.model.po.HPoTargetHeader


    }

    private boolean tryGetOrCreateTargetHeader(HDocument doc, HLocale locale,
            MergeType mergeType, boolean changed,
            PoTargetHeader fromTargetHeader) {
        HPoTargetHeader toTargetHeader = doc.getPoTargetHeaders().get(locale);
        if (toTargetHeader == null) {
            changed = true;
            toTargetHeader = new HPoTargetHeader();
            toTargetHeader.setTargetLanguage(locale);
            toTargetHeader.setDocument(doc);
            transferFromPoTargetHeader(fromTargetHeader, toTargetHeader,
                    MergeType.IMPORT); // return
                                       // value
                                       // not
                                       // needed
View Full Code Here


            return null;
        }
    }

    public int getNumPlurals(HDocument document, HLocale hLocale) {
        HPoTargetHeader headers = document.getPoTargetHeaders().get(hLocale);
        String headerEntries = headers != null ? headers.getEntries() : "";
        return getNPluralForms(headerEntries, hLocale);
    }
View Full Code Here

            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 {
                // If no header is found, use a default empty header for
                // generation
                // purposes
                fromHeader = new HPoTargetHeader();
                fromHeader.setEntries("");
            }
            transferToPoTargetHeader(fromHeader, poTargetHeader, hTargets,
                    locale);
            to.add(poTargetHeader);
        }
View Full Code Here

            }
        }

        for (Map.Entry<HLocale, HPoTargetHeader> entry : newDoc
                .getPoTargetHeaders().entrySet()) {
            HPoTargetHeader oldTargetHeader =
                    existingDoc.getPoTargetHeaders().get(
                            entry.getValue().getTargetLanguage());

            assertThat(entry.getValue().getEntries()).isEqualTo(
                    oldTargetHeader.getEntries());
            assertThat(entry.getValue().getTargetLanguage()).isEqualTo(
                    oldTargetHeader.getTargetLanguage());
            assertThat(entry.getValue().getDocument()).isEqualTo(newDoc);

            if (entry.getValue().getComment() != null) {
                assertThat(entry.getValue().getComment().getId()).isNotEqualTo(
                        oldTargetHeader.getComment().getId());
                assertThat(entry.getValue().getComment().getComment())
                        .isEqualTo(oldTargetHeader.getComment().getComment());
            }
        }
    }
View Full Code Here

    @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

    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

    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

    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);
View Full Code Here

    }

    @Test
    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);
View Full Code Here

TOP

Related Classes of org.zanata.model.po.HPoTargetHeader

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.