Package org.zanata.common

Examples of org.zanata.common.LocaleId


{
   public LocaleId unmarshal(String s) throws Exception
   {
      if (s == null)
         return null;
      return new LocaleId(s);
   }
View Full Code Here


        }

        List<HTextFlow> hTextFlows = textFlowDAO.findByIdList(idList);

        for (HTextFlow htf : hTextFlows) {
            LocaleId localeId = htf.getDocument().getLocale().getLocaleId();
            EditorTextFlow tf = new EditorTextFlow(htf.getResId(), localeId);
            transUnitUtils.transferToTextFlow(htf, tf);
            transUnits.put(htf.getId().toString(), new TransUnit(tf));
        }
        return Response.ok(transUnits).build();
View Full Code Here

                        Boolean.parseBoolean(params.get("merge").getString()) ? MergeType.AUTO
                                : MergeType.IMPORT;
                List<String> warnings =
                        translationServiceImpl.translateAllInDoc(projectSlug,
                                versionSlug, docId,
                                new LocaleId(params.get("targetLocale")
                                        .getString()), transRes, extensions,
                                mergeType);

                StringBuilder response = new StringBuilder();
                response.append("Status code: ");
View Full Code Here

        if (doc == null) {
            return Response.status(Response.Status.NOT_FOUND).build();
        }

        ContainerTranslationStatistics docStats =
                getDocStatistics(doc.getId(), new LocaleId(localeId));

        TranslationStatistics docWordStatistic =
                docStats.getStats(localeId, StatUnit.WORD);
        TranslationStatistics docMsgStatistic =
                docStats.getStats(localeId, StatUnit.MESSAGE);
View Full Code Here

    }

    @Override
    public Response put(String localeId, TranslationData data) {
        TranslationData requestData = data;
        HLocale locale = localeDAO.findByLocaleId(new LocaleId(localeId));
        HTextFlow textFlow =
                textFlowDAO.findById(requestData.getId().longValue());

        if (textFlow == null) {
            return Response.status(Response.Status.NOT_FOUND).build();
        }

        identity.checkPermission("modify-translation",
                textFlow.getDocument().getProjectIteration().getProject(),
                locale);

        // //Only support 1 translation update for the moment
        TransUnitUpdateRequest request =
                new TransUnitUpdateRequest(new TransUnitId(requestData.getId()
                        .longValue()), requestData.getContents(),
                        requestData.getStatus(), requestData.getRevision());

        List<TranslationResult> translationResults =
                translationServiceImpl.translate(new LocaleId(localeId),
                        Lists.newArrayList(request));

        TranslationResult result = translationResults.get(0);

        if (result.isVersionNumConflict()) {
View Full Code Here

    @Transactional
    public Response addLanguage(final String localeId) {
        new RunAsOperation() {
            @Override
            public void execute() {
                sampleProjectProfile.makeLanguage(new LocaleId(localeId));
            }
        }.addRole("admin").run();
        return Response.ok().build();
    }
View Full Code Here

                        localesCSV));
        List<LocaleId> locales =
                Lists.transform(localesIds, new Function<String, LocaleId>() {
                    @Override
                    public LocaleId apply(String input) {
                        return new LocaleId(input);
                    }
                });
        final HPerson hPerson = entityManager
            .createQuery("from HPerson p where p.account.username = :username",
                HPerson.class).setParameter("username", username).getSingleResult();
View Full Code Here

        createGlossaryRequest(query, display.getSearchType().getValue());
    }

    private void createGlossaryRequest(final String query,
            GetGlossary.SearchType searchType) {
        LocaleId srcLocale = LocaleId.EN_US;
        if (userWorkspaceContext.getSelectedDoc().getSourceLocale() != null) {
            srcLocale = userWorkspaceContext.getSelectedDoc().getSourceLocale();
        }
        final GetGlossary action =
                new GetGlossary(query, userWorkspaceContext
View Full Code Here

        // Collect the results for all states
        for (Map<String, Object> row : stats) {
            ContentState state = (ContentState) row.get("state");
            Long msgCount = (Long) row.get("msgCount");
            Long wordCount = (Long) row.get("wordCount");
            LocaleId localeId = (LocaleId) row.get("locale");

            TransUnitCount transUnitCount =
                    transUnitCountMap.get(localeId.getId());
            if (transUnitCount == null) {
                transUnitCount = new TransUnitCount();
                transUnitCountMap.put(localeId.getId(), transUnitCount);
            }

            TransUnitWords transUnitWords =
                    transUnitWordsMap.get(localeId.getId());
            if (transUnitWords == null) {
                transUnitWords = new TransUnitWords();
                transUnitWordsMap.put(localeId.getId(), transUnitWords);
            }

            transUnitCount.set(state, msgCount.intValue());
            transUnitWords.set(state, wordCount.intValue());
        }

        for (TransUnitCount stat : transUnitCountMap.values()) {
            stat.set(
                    ContentState.New,
                    StatisticsUtil.calculateUntranslated(
                            new Long(stat.getTotal()), stat));
        }
        for (TransUnitWords stat : transUnitWordsMap.values()) {
            stat.set(
                    ContentState.New,
                    StatisticsUtil.calculateUntranslated(
                            new Long(stat.getTotal()), stat));
        }

        // Merge into a single Stats object
        for (String locale : transUnitCountMap.keySet()) {
            ContainerTranslationStatistics newStats =
                    new ContainerTranslationStatistics();
            newStats.addStats(new TranslationStatistics(transUnitCountMap
                    .get(locale), locale));
            newStats.addStats(new TranslationStatistics(transUnitWordsMap
                    .get(locale), locale));

            if (newStats.getStats(locale, StatUnit.MESSAGE) != null
                    && newStats.getStats(locale, StatUnit.WORD) != null) {
                returnStats.put(new LocaleId(locale), newStats);
            }
        }

        return returnStats;
    }
View Full Code Here

            to.getRoles().add(hAccountRole);
        }

        hPerson.getLanguageMemberships().clear();
        for (String tribe : from.getTribes()) {
            HLocale hTribe = localeDAO.findByLocaleId(new LocaleId(tribe));
            if (hTribe == null)
                // generate error for missing tribe
                throw new NoLogWebApplicationException(Response
                        .status(Status.BAD_REQUEST)
                        .entity("Invalid tribe '" + tribe + "'").build());
View Full Code Here

TOP

Related Classes of org.zanata.common.LocaleId

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.