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

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


        assertThat(translations.getTextFlowTargets().size(), is(0)); // Expecting
                                                                     // no
                                                                     // translations

        // Make sure the headers are populated
        PoTargetHeader header =
                translations.getExtensions(true).findByType(
                        PoTargetHeader.class);
        assertThat(header, notNullValue());
        assertThat(header.getEntries().size(), greaterThan(0));

        // Make sure the header values are empty since the system does not have
        // any information for them
        for (HeaderEntry entry : header.getEntries()) {
            if (entry.getKey().equals(HeaderFields.KEY_LastTranslator)) {
                assertThat(entry.getValue().trim(), is(""));
            } else if (entry.getKey().equals(HeaderFields.KEY_PoRevisionDate)) {
                assertThat(entry.getValue().trim(), is(""));
            }
View Full Code Here


        Calendar poRevDate = Calendar.getInstance();
        poRevDate.add(Calendar.YEAR, 1); // 1 year in the future
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mmZ");

        // Add initial headers to the translations
        PoTargetHeader transHeader = new PoTargetHeader();
        transHeader.getEntries().add(
                new HeaderEntry(HeaderFields.KEY_LastTranslator,
                        "Test User <test@zanata.org>"));
        transHeader.getEntries().add(
                new HeaderEntry(HeaderFields.KEY_PoRevisionDate, dateFormat
                        .format(poRevDate.getTime()))); // Date in the future
        entity.getExtensions(true).add(transHeader);

        // Push the translations
        ClientResponse<String> putResponse =
                transResource.putTranslations("my.txt", de_DE, entity,
                        new StringSet("gettext"));
        assertThat(putResponse.getResponseStatus(), is(Status.OK));
        getEm().flush();
        getEm().clear();

        // Get the translations with PO headers
        ClientResponse<TranslationsResource> transResponse =
                transResource.getTranslations("my.txt", de_DE, new StringSet(
                        "gettext"));
        TranslationsResource translations = transResponse.getEntity();

        // Make sure the headers are populated
        PoTargetHeader header =
                translations.getExtensions(true).findByType(
                        PoTargetHeader.class);
        assertThat(header, notNullValue());
        assertThat(header.getEntries().size(), greaterThan(0));

        // Make sure the header values are the same as the ones pushed with the
        // document
        for (HeaderEntry entry : header.getEntries()) {
            if (entry.getKey().equals(HeaderFields.KEY_LastTranslator)) {
                assertThat(entry.getValue().trim(),
                        is("Test User <test@zanata.org>"));
            } else if (entry.getKey().equals(HeaderFields.KEY_PoRevisionDate)) {
                assertThat(entry.getValue().trim(),
View Full Code Here

        translations = response.getEntity();
        assertThat(translations.getTextFlowTargets().size(), greaterThan(0));

        // Make sure the headers are now populated
        PoTargetHeader header =
                translations.getExtensions(true).findByType(
                        PoTargetHeader.class);
        assertThat(header, notNullValue());
        assertThat(header.getEntries().size(), greaterThan(0));

        // Make sure the headers have the correct value
        for (HeaderEntry entry : header.getEntries()) {
            if (entry.getKey().equals(HeaderFields.KEY_LastTranslator)) {
                assertThat(entry.getValue().trim(),
                        is("Administrator <root@localhost>"));
            } else if (entry.getKey().equals(HeaderFields.KEY_PoRevisionDate)) {
                assertThat(entry.getValue().trim().length(), greaterThan(0));
View Full Code Here

        TranslationsResource translations = response.getEntity();
        assertThat(translations.getTextFlowTargets().size(), greaterThan(0));

        // Make sure the headers are present
        PoTargetHeader header =
                translations.getExtensions(true).findByType(
                        PoTargetHeader.class);
        assertThat(header, notNullValue());
        assertThat(header.getEntries().size(), greaterThan(0));

        // Make sure the headers have the correct value
        for (HeaderEntry entry : header.getEntries()) {
            if (entry.getKey().equals(HeaderFields.KEY_LastTranslator)) {
                assertThat(entry.getValue().trim(),
                        is("Sample User <user1@localhost>"));
            } else if (entry.getKey().equals(HeaderFields.KEY_PoRevisionDate)) {
                assertThat(entry.getValue().trim().length(), greaterThan(0));
View Full Code Here

        TranslationsResource tr = new TranslationsResource();
        TextFlowTarget target =
                newTextFlowTarget("FOOD", "Sauerkraut", "translator comment");
        tr.getTextFlowTargets().add(target);

        PoTargetHeader targetHeader = new PoTargetHeader();
        targetHeader.setComment("target comment");
        List<HeaderEntry> entries = targetHeader.getEntries();
        entries.add(new HeaderEntry("Project-Id-Version", "ja"));
        tr.getExtensions(true).add(targetHeader);

        transResource.putTranslations(id, DE, tr, extGettextComment);
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.