IDT - the type of the technical identifier associated to this entity.public interface ITranslatableEntity<IDT extends Serializable> extends IEntity<IDT>
| Modifier and Type | Method and Description |
|---|---|
void |
applyTranslation(String languageCode)
Apply an existing translation on this translatable entity.
|
void |
deleteTranslation(String languageCode)
Deletes an existing translation from this translatable entity.
|
void |
deleteTranslations(List<String> languageCodes)
Function used to delete one or multiple existing translations from the entity.
|
String |
getDefaultLanguageCode()
Gets the language code which was used when the entity was created.
|
ITranslation |
getTranslation(String languageCode)
Gets a translation (corresponding to a specified language code) for the entity.
|
String |
getTranslationLanguageCode()
Gets the language code associated to translations which have been applied to the entity.
|
Map<String,ITranslation> |
getTranslations()
Gets multiple translations in multiple languages for this translatable entity.
|
Boolean |
isTranslated()
Function used to indicate if the entity has been translated of if its fields are in its default
language.
|
void |
setDefaultLanguageCode(String defaultLanguageCode)
Sets the language code which was used when the entity was created.
|
void |
setTranslation(ITranslation translation)
Adds a new translation or update an existing one for the entity.
|
void |
setTranslationLanguageCode(String translationLanguageCode)
Sets the language code associated to the translations which have been applied to the entity.
|
void |
setTranslations(Map<String,ITranslation> translations)
Sets multiple translations in multiple languages for this translatable entity.
|
void applyTranslation(String languageCode)
languageCode - The code of the targeted language translation.IllegalStateException - If no translation with the language code `languageCode` has been
found.void deleteTranslation(String languageCode)
WARNING: The provided language code is not case sensitive, but, internally the language code which is used and stored is ALWAYS converted in uppercase.
languageCode - The code of the language for which one to delete a translation.IllegalStateException - If no translation with the language code `languageCode` has not
been registered.void deleteTranslations(List<String> languageCodes)
WARNING: The provided language codes are not case sensitive, but, internally the language codes which are used and stored are ALWAYS converted in uppercase.
languageCodes - An array with language codes associated to translations to be deleted, if
this parameter is `null` then all the translations are deleted.IllegalStateException - if one (or more) translation with one of the provided language
has not been registered. If this exception is thrown then the translatable entity is
not modified.String getDefaultLanguageCode()
WARNING: The language code returned by this function is always expressed in uppercase even if you provided a language code to the entity using a lower case syntax. Internally translatable entities always store language codes in upper case.
ITranslation getTranslation(String languageCode)
WARNING: The provided language code is not case sensitive, but, internally the language code which is used and stored is ALWAYS converted in uppercase.
languageCode - The language code for which one to get a translation.IllegalStateException - if no translation have been found for the specified language
code.String getTranslationLanguageCode()
The translation language code should only be used when you have to translate an entity in one language to display informations on a GUI (also in one language). If you have to create a GUI for persons responsible of the translations (i.e the translators) then you'll need to attach all the available translations in all languages to you entities. In this cas you should used the `getTranslations()` and `setTranslations()` functions to manage a list of all the translations in all languages attached to the entity. WARNING: The provided language code is not case sensitive, but, internally the language code which is used and stored is ALWAYS converted in uppercase.
Map<String,ITranslation> getTranslations()
If you have to display an entity in only one language then do not use the `getTranslations()` and `setTranslations()` function but prefer the `getTranslationLanguageCode()` and `setTranslationLanguageCode()` functions which are used to manage only one translation (i.e in only one language), that's to say to translate the entity in one target language only.
Boolean isTranslated()
void setDefaultLanguageCode(String defaultLanguageCode)
WARNING: The provided language code is not case sensitive, but, internally the language code which is used and stored is ALWAYS converted in uppercase.
defaultLanguageCode - The default language code to set, this string must be compliant with
the ISO639-1 standard.void setTranslationLanguageCode(String translationLanguageCode)
The translation language code should only be used when you have to translate an entity in one language to display informations on a GUI (also in one language). If you have to create a GUI for persons responsible of the translations (i.e the translators) then you'll need to attach all the available translations in all languages to you entities. In this cas you should used the `getTranslations()` and `setTranslations()` functions to manage a list of all the translations in all languages attached to the entity. WARNING: The provided language code is not case sensitive, but, internally the language code which is used and stored is ALWAYS converted in uppercase.
translationLanguageCode - The translation language code to set, this string must be
compliant with the ISO639-1 standard.void setTranslation(ITranslation translation)
translation - The new translation to add or an existing translation to update.IllegalStateException - if the entity is already translated using a the "one language
mode".void setTranslations(Map<String,ITranslation> translations)
If you have to display an entity in only one language then do not use the `getTranslations()` and `setTranslations()` function but prefer the `getTranslationLanguageCode()` and `setTranslationLanguageCode()` functions which are used to manage only one translation (i.e in only one language), that's to say to translate the entity in one target language only.
translations - The translations to set.Copyright © 2017 GOMOOB. All rights reserved.