Package org.zanata.adapter.po

Examples of org.zanata.adapter.po.PoWriter2


        }

        @Override
        public void write(OutputStream output) throws IOException,
                WebApplicationException {
            PoWriter2 writer = new PoWriter2(false, offlinePo);
            writer.writePo(output, "UTF-8", this.resource, this.transRes);
        }
View Full Code Here


        }

        @Override
        public void write(OutputStream output) throws IOException,
                WebApplicationException {
            PoWriter2 writer = new PoWriter2(false, offlinePot);
            writer.writePot(output, "UTF-8", resource);
        }
View Full Code Here

        final File downloadFile =
                fileSystemServiceImpl.createDownloadStagingFile("zip");
        final FileOutputStream output = new FileOutputStream(downloadFile);
        final ZipOutputStream zipOutput = new ZipOutputStream(output);
        zipOutput.setMethod(ZipOutputStream.DEFLATED);
        final PoWriter2 poWriter = new PoWriter2(false, !isPoProject);
        final Set<String> extensions = new HashSet<String>();

        extensions.add("gettext");
        extensions.add("comment");

        // Generate the download descriptor file
        String downloadId =
                fileSystemServiceImpl.createDownloadDescriptorFile(downloadFile,
                        projectSlug + "_" + iterationSlug + "_" + localeId
                                + ".zip", userName);

        // Add the config file at the root of the project directory
        String configFilename =
                projectDirectory
                        + configurationServiceImpl.getConfigurationFileName();
        zipOutput.putNextEntry(new ZipEntry(configFilename));
        zipOutput.write(configurationServiceImpl.getConfigForOfflineTranslation(
                projectSlug, iterationSlug, hLocale).getBytes());
        zipOutput.closeEntry();
        handle.increaseProgress(1);

        final List<HDocument> allIterationDocs =
                documentDAO
                        .getAllByProjectIteration(projectSlug, iterationSlug);
        for (HDocument document : allIterationDocs) {
            // Stop the process if signaled to do so
            if (handleOpt.isPresent() && handleOpt.get().isCancelled()) {
                zipOutput.close();
                downloadFile.delete();
                fileSystemServiceImpl.deleteDownloadDescriptorFile(downloadId);
                return null;
            }

            TranslationsResource translationResource =
                    new TranslationsResource();
            List<HTextFlowTarget> hTargets =
                    textFlowTargetDAO.findTranslations(document, hLocale);
            resourceUtils.transferToTranslationsResource(translationResource,
                    document, hLocale, extensions, hTargets,
                    Optional.<String> absent());

            Resource res = resourceUtils.buildResource(document);

            String filename = localeDirectory + document.getDocId() + ".po";
            zipOutput.putNextEntry(new ZipEntry(filename));
            poWriter.writePo(zipOutput, "UTF-8", res, translationResource);
            zipOutput.closeEntry();

            if( handleOpt.isPresent() ) {
                handleOpt.get().increaseProgress(1);
            }
View Full Code Here

TOP

Related Classes of org.zanata.adapter.po.PoWriter2

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.