Interface TranslationService

All Known Implementing Classes:
TranslationServiceImpl

public interface TranslationService
  • Method Details

    • 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
    • getAssignableEntityType

      TranslatedEntity getAssignableEntityType(String className)
      Gets the TranslatedEntity based on the passed className. The TranslatedEntity may be an assignable.
      Parameters:
      className -
      Returns:
    • 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

      javax.cache.Cache<String,Object> getCache()
      Get the translation specific cache (different than the level-2 hibernate cache)
      Returns:
      the translation specific cache
    • getDefaultTranslationValue

      String getDefaultTranslationValue(Object entity, String property, Locale locale, String requestedDefaultValue)
      Intended for use with the DynamicTranslationProvider to determine the default value when a translation was not provided.

      The default implementation of this method relies on a system property "returnBlankTranslationForNotDefaultLocale". If this is true, the system will return blank if the language of the defaultLocale does not match the language of the passed in locale.

      For example, consider the "longDescription" property and the system default locale is "en". If this method is called for a locale of "en_CA", the requestedDefaultValue will be returned. If the method is called with a value of "fr_CA", blank will be returned.

      Parameters:
      entity -
      property -
      locale -
      requestedDefaultValue -
      Returns:
    • findAllTranslationEntries

      List<Translation> findAllTranslationEntries(TranslatedEntity translatedEntity, ResultType standard, List<String> entityIds)
      Find all the available translations for the given params.
      Parameters:
      translatedEntity -
      standard - param drives whether to look for entries at a template level or standard site level (multitenant concepts). Can be IGNORE. Any multitenant behavior is ignored in the absence of the multitenant module.
      entityIds - the Translation.getEntityId() to restrict the results by
      Returns: