@Override public void process(WebRequest request) { TranslationConsiderationContext.setTranslationConsiderationContext(getTranslationEnabled()); TranslationConsiderationContext.setTranslationService(translationService); } }
public static boolean hasTranslation() { return isTranslationConsiderationContextEnabled() != null && isTranslationConsiderationContextEnabled() && getTranslationService() != null; }
/** * If translations are enabled, this method will look for a translation for the specified field. If translations are * disabled or if this particular field did not have a translation, it will return back the defaultValue. * * @param obj * @param field * @param defaultValue * @return the translated value */ public static String getValue(Object obj, String field, final String defaultValue) { String valueToReturn = defaultValue; if (TranslationConsiderationContext.hasTranslation()) { TranslationService translationService = TranslationConsiderationContext.getTranslationService(); Locale locale = BroadleafRequestContext.getBroadleafRequestContext().getJavaLocale(); String translatedValue = translationService.getTranslatedValue(obj, field, locale); if (StringUtils.isNotBlank(translatedValue)) { valueToReturn = translatedValue; } else { valueToReturn = translationService.getDefaultTranslationValue(obj, field, locale, defaultValue); } } return valueToReturn; }
result = ExtensionResultStatusType.HANDLED; TranslationConsiderationContext.setTranslationConsiderationContext(getTranslationEnabled()); TranslationConsiderationContext.setTranslationService(translationService); BroadleafRequestContext tempContext = BroadleafRequestContext.getBroadleafRequestContext(); if (tempContext == null) {