Package org.broadleafcommerce.common.i18n.domain

Examples of org.broadleafcommerce.common.i18n.domain.Translation


    @RequestMapping(value = "/update", method = RequestMethod.GET)
    public String showUpdateTranslation(HttpServletRequest request, HttpServletResponse response, Model model,
            @ModelAttribute(value="form") TranslationForm form, BindingResult result) throws Exception {
        adminRemoteSecurityService.securityCheck(form.getCeilingEntity(), EntityOperationType.FETCH);
       
        Translation t = translationService.findTranslationById(form.getTranslationId());
        form.setTranslatedValue(t.getTranslatedValue());
       
        EntityForm entityForm = formService.buildTranslationForm(form);
        entityForm.setId(String.valueOf(form.getTranslationId()));
       
        model.addAttribute("entityForm", entityForm);
View Full Code Here


    @Transactional("blTransactionManager")
    public Translation save(String entityType, String entityId, String fieldName, String localeCode,
            String translatedValue) {
        TranslatedEntity te = getEntityType(entityType);
       
        Translation translation = getTranslation(te, entityId, fieldName, localeCode);
       
        if (translation == null) {
            translation = dao.create();
            translation.setEntityType(te);
            translation.setEntityId(entityId);
            translation.setFieldName(fieldName);
            translation.setLocaleCode(localeCode);
        }
       
        translation.setTranslatedValue(translatedValue);
        return save(translation);
    }
View Full Code Here

    }
   
    @Override
    @Transactional("blTransactionManager")
    public Translation update(Long translationId, String localeCode, String translatedValue) {
        Translation t = dao.readTranslationById(translationId);
       
        // Check to see if there is another translation that matches this updated one. We'll remove it if it exists
        Translation t2 = dao.readTranslation(t.getEntityType(), t.getEntityId(), t.getFieldName(), localeCode);
        if (t2 != null && t != t2) {
            dao.delete(t2);
        }
       
        t.setLocaleCode(localeCode);
View Full Code Here

    }
   
    @Override
    @Transactional("blTransactionManager")
    public void deleteTranslationById(Long translationId) {
        Translation t = dao.readTranslationById(translationId);
        dao.delete(t);
    }
View Full Code Here

        String localeCountryCode = localeCode;
        if (StringUtils.isNotBlank(locale.getCountry())) {
            localeCountryCode += "_" + locale.getCountry();
        }

        Translation translation;
       
        // First, we'll try to look up a country language combo (en_GB), utilizing the cache
        String countryCacheKey = getCacheKey(entityType, entityId, property, localeCountryCode);
        Element countryValue = getCache().get(countryCacheKey);
        if (countryValue != null) {
            statisticsService.addCacheStat(CacheStatType.TRANSLATION_CACHE_HIT_RATE.toString(), true);
            translation = (Translation) countryValue.getObjectValue();
        } else {
            statisticsService.addCacheStat(CacheStatType.TRANSLATION_CACHE_HIT_RATE.toString(), false);
            translation = getTranslation(entityType, entityId, property, localeCountryCode);
            if (translation == null) {
                translation = new TranslationImpl();
            }
            getCache().put(new Element(countryCacheKey, translation));
        }
       
        // If we don't find one, let's try just the language (en), again utilizing the cache
        if (translation.getTranslatedValue()==null) {
            String nonCountryCacheKey = getCacheKey(entityType, entityId, property, localeCode);
            Element nonCountryValue = getCache().get(nonCountryCacheKey);
            if (nonCountryValue != null) {
                statisticsService.addCacheStat(CacheStatType.TRANSLATION_CACHE_HIT_RATE.toString(), true);
                translation = (Translation) nonCountryValue.getObjectValue();
            } else {
                statisticsService.addCacheStat(CacheStatType.TRANSLATION_CACHE_HIT_RATE.toString(), false);
                translation = getTranslation(entityType, entityId, property, localeCode);
                if (translation == null) {
                    translation = new TranslationImpl();
                }
                getCache().put(new Element(nonCountryCacheKey, translation));
            }
        }
       
        // If we have a match on a translation, use that instead of what we found on the entity.
        if (StringUtils.isNotBlank(translation.getTranslatedValue())) {
            return translation.getTranslatedValue();
        }
       
        return null;
    }
View Full Code Here

TOP

Related Classes of org.broadleafcommerce.common.i18n.domain.Translation

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.