Class Translation

java.lang.Object
io.goobi.viewer.model.translations.Translation
Direct Known Subclasses:
CampaignTranslation, CMSCollectionTranslation, LicenseTypePlaceholderInfo, MaintenanceModeTranslation, MapTranslation, MessagesTranslation, TermsOfUseTranslation

@MappedSuperclass public class Translation extends Object
Represents a single translated value for a specific language tag.
  • Field Details

    • id

      protected Long id
      Unique database ID.
    • tag

      protected String tag
      An additional optional field used to identify the purpose or categorization of a translation. Useful if an object has more than one relationship with Translation entities and needs to distinguish them in some way
    • language

      protected String language
    • translationValue

      protected String translationValue
  • Constructor Details

    • Translation

      public Translation()
      Creates a new Translation instance.
    • Translation

      public Translation(String language, String translationValue)
      Creates a new Translation instance.
      Parameters:
      language - ISO language code for this translation
      translationValue - translated text value
    • Translation

      public Translation(String language, String tag, String translationValue)
      Creates a new Translation instance.
      Parameters:
      language - ISO language code for this translation
      tag - category or purpose label for this translation
      translationValue - translated text value
    • Translation

      public Translation(Translation t)
      Clones constructor.
      Parameters:
      t - translation to copy
  • Method Details

    • getTranslation

      public static String getTranslation(List<? extends Translation> translations, String lang, String tag)
      getTranslation.
      Parameters:
      translations - list of translations to search in
      lang - ISO language code of the desired translation
      tag - category label to match against translation entries
      Returns:
      the translation value for the given language and tag, or null if not found
    • getTranslation

      public static String getTranslation(List<? extends Translation> translations, String lang, String tag, boolean useFallback)
      getTranslation.
      Parameters:
      translations - list of translations to search in
      lang - ISO language code of the desired translation
      tag - category label to match against translation entries
      useFallback - if no translation for lang exists, use the application default language
      Returns:
      the translation value for the given language and tag, falling back to default language if requested and necessary
    • setTranslation

      public static void setTranslation(List<Translation> translations, String lang, String translationValue, String tag)
    • getId

      public Long getId()
      Getter for the field id.
      Returns:
      the database identifier of this translation entry
    • setId

      public void setId(Long id)
      Setter for the field id.
      Parameters:
      id - the database identifier to set
    • getTag

      public String getTag()
      Getter for the field tag.
      Returns:
      the message key or category tag identifying this translation
    • setTag

      public void setTag(String tag)
      Setter for the field tag.
      Parameters:
      tag - the message key or category tag identifying this translation to set
    • getLanguage

      public String getLanguage()
      Getter for the field language.
      Returns:
      the ISO 639-1 language code for this translation
    • setLanguage

      public void setLanguage(String language)
      Setter for the field language.
      Parameters:
      language - the ISO 639-1 language code for this translation to set
    • getTranslationValue

      public String getTranslationValue()
      Getter for the field translationValue.
      Returns:
      the translated text value
    • setTranslationValue

      public void setTranslationValue(String translationValue)
      Setter for the field translationValue.
      Parameters:
      translationValue - the translated text value to set
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Hash code is build from hashCode of language.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value for this object
    • equals

      public boolean equals(Object obj)
      Two Translations are equal if they are of the same class and both tag and language match.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare to this translation
      Returns:
      true if the given object is equal to this instance, false otherwise
    • isEmpty

      public boolean isEmpty()