@Override protected int getMaxProgress() { LocaleService localeService = (LocaleService) Component.getInstance(LocaleServiceImpl.class); List<HLocale> localeList = localeService.getSupportedLanguageByProjectIteration( projectIteration.getProject().getSlug(), projectIteration.getSlug()); return projectIteration.getDocuments().size() * localeList.size(); }
public GetTransUnitListHandler createGetTransUnitListHandlerWithBehavior( DocumentId documentId, List<HTextFlow> hTextFlows, HLocale hLocale, int startIndex, int count) { // @formatter:off GetTransUnitListHandler handler = SeamAutowire.instance() .use("identity", identity) .use("textFlowDAO", textFlowDAO) .use("textFlowSearchServiceImpl", textFlowSearchServiceImpl) .use("localeServiceImpl", localeServiceImpl) .use("resourceUtils", resourceUtils) .autowire(GetTransUnitListHandler.class); // @formatter:on int maxSize = Math.min(startIndex + count, hTextFlows.size()); when(textFlowDAO.getTextFlows(documentId, startIndex, count)) .thenReturn(hTextFlows.subList(startIndex, maxSize)); when(localeServiceImpl.validateLocaleByProjectIteration( any(LocaleId.class), anyString(), anyString())) .thenReturn(hLocale); when(resourceUtils.getNumPlurals(any(HDocument.class), any(HLocale.class))).thenReturn(1); // trans unit navigation index handler when(textFlowDAO.getNavigationByDocumentId( eq(documentId.getId()), eq(hLocale), isA(ResultTransformer.class), isA(FilterConstraints.class))) .thenReturn(hTextFlows); return handler; }
public List<HLocale> suggestLocales(final String query) { if (allLocales == null) { allLocales = localeServiceImpl.getAllJavaLanguages(); } Collection<LocaleId> filtered = Collections2.filter( allLocales, new Predicate<LocaleId>() { @Override public boolean apply(LocaleId input) { return input.getId().startsWith(query); } }); return new ArrayList<HLocale>( Collections2.transform( filtered, new Function<LocaleId, HLocale>() { @Override public HLocale apply(@Nullable LocaleId from) { return new HLocale(from); } })); }
public List<HLocale> getTranslationLocale(String projectSlug, String iterationSlug) { if (authenticatedAccount == null) { return Collections.emptyList(); } return localeServiceImpl.getTranslation( projectSlug, iterationSlug, authenticatedAccount.getUsername()); }
public String save() { if (!isLanguageNameValid()) { return null; // not success } LocaleId locale = new LocaleId(language); localeServiceImpl.save(locale, enabledByDefault); return "success"; }
public void fectchLocaleFromJava() { List<LocaleId> locale = localeServiceImpl.getAllJavaLanguages(); List<SelectItem> localeList = new ArrayList<SelectItem>(); for (LocaleId var : locale) { SelectItem op = new SelectItem(var.getId(), var.getId()); localeList.add(op); } localeStringList = localeList; }
public boolean isLanguageNameValid() { this.languageNameValidationMessage = null; // reset this.languageNameWarningMessage = null; // reset if (language.length() > LENGTH_LIMIT) { this.uLocale = null; this.languageNameValidationMessage = msgs.get("jsf.language.validation.Invalid"); return false; } // Cannot use FacesMessages as they are request scoped. // Cannot use UI binding as they don't work in Page scoped beans // TODO Use the new (since 1.7) FlashScopeBean // Check that locale Id is syntactically valid LocaleId localeId; try { localeId = new LocaleId(language); } catch (IllegalArgumentException iaex) { this.languageNameValidationMessage = msgs.get("jsf.language.validation.Invalid"); return false; } // check for already registered languages if (localeServiceImpl.localeExists(localeId)) { this.languageNameValidationMessage = msgs.get("jsf.language.validation.Existing"); return false; } // Check for plural forms if (resourceUtils.getPluralForms(localeId, false) == null) { this.languageNameWarningMessage = msgs.get("jsf.language.validation.UnknownPluralForm"); } // Check for similar already registered languages (warning) List<HLocale> similarLangs = localeDAO.findBySimilarLocaleId(localeId); if (similarLangs.size() > 0) { this.languageNameWarningMessage = msgs.get("jsf.language.validation.SimilarLocaleFound") + similarLangs.get(0).getLocaleId().getId(); } return true; }
public List<HLocale> getSupportedLocales(String projectSlug, String versionSlug) { return localeServiceImpl.getSupportedLanguageByProjectIteration(projectSlug, versionSlug); }