org.broadleafcommerce.common.i18n.service
Interface TranslationService

All Known Implementing Classes:
TranslationServiceImpl

public interface TranslationService


Method Summary
 void deleteTranslationById(Long translationId)
          Deletes the given translations
 Translation findTranslationById(Long id)
          Find a translation instance by its primary key value.
 net.sf.ehcache.Cache getCache()
          Get the translation specific cache (different than the level-2 hibernate cache)
 String getTranslatedValue(Object entity, String property, Locale locale)
          Returns the translated value of the property for the given entity.
 Translation getTranslation(TranslatedEntity entity, String entityId, String fieldName, String localeCode)
          Attempts to find the translation object for the given parameters
 List<Translation> getTranslations(String ceilingEntityClassname, String entityId, String property)
          Finds all current translations for the specified field
 void removeTranslationFromCache(Translation translation)
          Remove a translation instance from the translation specific cache (different than level-2 hibernate cache)
 Translation save(String entityType, String entityId, String fieldName, String localeCode, String translatedValue)
          Creates a new translation object for the requested parameters, saves it, and returns the saved instance.
 Translation save(Translation translation)
          Persists the given translation
 Translation update(Long translationId, String localeCode, String translatedValue)
          Updates the given translation id with the new locale code and translated value
 

Method Detail

save

Translation save(Translation translation)
Persists the given translation

Parameters:
translation -
Returns:
the persisted translation

save

Translation save(String entityType,
                 String entityId,
                 String fieldName,
                 String localeCode,
                 String translatedValue)
Creates a new translation object for the requested parameters, saves it, and returns the saved instance. Note: This method will overwrite a previously existing translation if it matches on entityType, entityId, fieldName, and localeCode.

Parameters:
entityType -
entityId -
fieldName -
localeCode -
translatedValue -
Returns:
the persisted translation

update

Translation update(Long translationId,
                   String localeCode,
                   String translatedValue)
Updates the given translation id with the new locale code and translated value

Parameters:
translationId -
localeCode -
translatedValue -
Returns:
the persisted translation

deleteTranslationById

void deleteTranslationById(Long translationId)
Deletes the given translations

Parameters:
translationId -

getTranslations

List<Translation> getTranslations(String ceilingEntityClassname,
                                  String entityId,
                                  String property)
Finds all current translations for the specified field

Parameters:
ceilingEntityClassname -
entityId -
property -
Returns:
the list of translations

getTranslation

Translation getTranslation(TranslatedEntity entity,
                           String entityId,
                           String fieldName,
                           String localeCode)
Attempts to find the translation object for the given parameters

Parameters:
entity -
entityId -
fieldName -
localeCode -
Returns:
the persisted translation

getTranslatedValue

String getTranslatedValue(Object entity,
                          String property,
                          Locale locale)
Returns the translated value of the property for the given entity. For example, if entity is an instance of Product and property is equal to name, this method might return "Hoppin' Hot Sauce" if we are in an English locale and "Salsa de la Muerte Saltante" if we are in a Spanish locale. If a country is set on the locale (locale code en_GB for example), we will first look for a translation that matches en_GB, and then look for a translation for en. If a translated value for the given locale is not available, it will return null.

Parameters:
entity -
property -
locale -
Returns:
the translated value of the property for the given entity

removeTranslationFromCache

void removeTranslationFromCache(Translation translation)
Remove a translation instance from the translation specific cache (different than level-2 hibernate cache)

Parameters:
translation - The translation instance to remove

findTranslationById

Translation findTranslationById(Long id)
Find a translation instance by its primary key value.

Parameters:
id - the primary key value
Returns:

getCache

net.sf.ehcache.Cache getCache()
Get the translation specific cache (different than the level-2 hibernate cache)

Returns:
the translation specific cache


Copyright © 2013. All Rights Reserved.