Class Translation
java.lang.Object
io.goobi.viewer.model.translations.Translation
- Direct Known Subclasses:
CampaignTranslation,CMSCollectionTranslation,LicenseTypePlaceholderInfo,MaintenanceModeTranslation,MapTranslation,MessagesTranslation,TermsOfUseTranslation
Represents a single translated value for a specific language tag.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new Translation instance.Clones constructor.Translation(String language, String translationValue) Creates a new Translation instance.Translation(String language, String tag, String translationValue) Creates a new Translation instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTwo Translations are equal if they are of the same class and both tag and language match.getId()Getter for the fieldid.Getter for the fieldlanguage.getTag()Getter for the fieldtag.static StringgetTranslation(List<? extends Translation> translations, String lang, String tag) getTranslation.static StringgetTranslation(List<? extends Translation> translations, String lang, String tag, boolean useFallback) getTranslation.Getter for the fieldtranslationValue.inthashCode()Hash code is build from hashCode of language.booleanisEmpty()voidSetter for the fieldid.voidsetLanguage(String language) Setter for the fieldlanguage.voidSetter for the fieldtag.static voidsetTranslation(List<Translation> translations, String lang, String translationValue, String tag) voidsetTranslationValue(String translationValue) Setter for the fieldtranslationValue.toString()
-
Field Details
-
id
Unique database ID. -
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
-
translationValue
-
-
Constructor Details
-
Translation
public Translation()Creates a new Translation instance. -
Translation
Creates a new Translation instance.- Parameters:
language- ISO language code for this translationtranslationValue- translated text value
-
Translation
Creates a new Translation instance.- Parameters:
language- ISO language code for this translationtag- category or purpose label for this translationtranslationValue- translated text value
-
Translation
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 inlang- ISO language code of the desired translationtag- 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 inlang- ISO language code of the desired translationtag- category label to match against translation entriesuseFallback- 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
Getter for the fieldid.- Returns:
- the database identifier of this translation entry
-
setId
Setter for the fieldid.- Parameters:
id- the database identifier to set
-
getTag
Getter for the fieldtag.- Returns:
- the message key or category tag identifying this translation
-
setTag
Setter for the fieldtag.- Parameters:
tag- the message key or category tag identifying this translation to set
-
getLanguage
Getter for the fieldlanguage.- Returns:
- the ISO 639-1 language code for this translation
-
setLanguage
Setter for the fieldlanguage.- Parameters:
language- the ISO 639-1 language code for this translation to set
-
getTranslationValue
Getter for the fieldtranslationValue.- Returns:
- the translated text value
-
setTranslationValue
Setter for the fieldtranslationValue.- Parameters:
translationValue- the translated text value to set
-
toString
-
hashCode
public int hashCode()Hash code is build from hashCode of language. -
equals
Two Translations are equal if they are of the same class and both tag and language match. -
isEmpty
public boolean isEmpty()
-