Package com.e1c.langtool.storage
Interface ITranslationStorageProvider.ContextStorage
- All Superinterfaces:
ITranslationStorageProvider.Storage
- All Known Implementing Classes:
ContextFileStorage
- Enclosing interface:
- ITranslationStorageProvider
public static interface ITranslationStorageProvider.ContextStorage
extends ITranslationStorageProvider.Storage
The Interface for context storage of translation strings. Storage should have type
context
this means storage provides translation for given resource id of the project and feature key in the resource.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.e1c.langtool.storage.ITranslationStorageProvider.Storage
ITranslationStorageProvider.Storage.Type -
Method Summary
Modifier and TypeMethodDescriptiondefault StringgetComment(ContextTranslationKey key, TranslateLanguage language) Gets the comment by the translation key.default StringgetTranslation(FeatureValue source, TranslateLanguage language) Gets the translation from storage.getTranslation(ContextTranslationKey key, TranslateLanguage language) Gets the translation from the context storage.getType()Returns the type of translation storage.booleanhasKeyForValue(String value, TranslateLanguage language, ContextTranslationKey skipTranslationKey) Checks that context storage has key for the value except the given skip key.default voidmoveComment(ContextTranslationKey fromKey, ContextTranslationKey toKey, TranslateLanguage language, boolean autoSave) Move only comment from one translation key to another.default voidmoveTranslation(FeatureValue fromSource, FeatureValue toSource, TranslateLanguage language, boolean autoSave) Move translation inside the storage from one key to enother.voidmoveTranslation(ContextTranslationKey fromKey, ContextTranslationKey toKey, TranslateLanguage language, boolean autoSave) Move translation from one key to another inside this single storage.default voidremoveComment(ContextTranslationKey key, TranslateLanguage language, boolean autoSave) Removes the comment of the translation key.default voidremoveTranslation(FeatureValue source, TranslateLanguage language, boolean autoSave) Removes the translation from storage.voidremoveTranslation(ContextTranslationKey key, TranslateLanguage language, boolean autoSave) Removes the translation.Map<org.eclipse.core.resources.IFile,byte[]> saveFiles(Collection<ContextTranslationKey> affectedKeys, TranslateLanguage language, com.google.common.hash.HashFunction hashFunction) Saves affected translation files explicitly in case if translation data existdefault voidsetComment(ContextTranslationKey key, TranslateLanguage language, String comment, boolean autoSave) Sets the comment for some translation key.default voidsetTranslation(FeatureValue source, TranslateLanguage language, String translation, boolean autoSave) Sets the translation.voidsetTranslation(ContextTranslationKey key, TranslateLanguage language, String translation, boolean autoSave) Sets the translation of context storage.Methods inherited from interface com.e1c.langtool.storage.ITranslationStorageProvider.Storage
addBatchUpdateNotification, addValueChangedListener, beginBatchUpdate, endBatchUpdate, getId, getSegment, isReadOnly, removeValueChangedListener
-
Method Details
-
getType
Description copied from interface:ITranslationStorageProvider.StorageReturns the type of translation storage.- Specified by:
getTypein interfaceITranslationStorageProvider.Storage- Returns:
- the type of storage
- See Also:
-
getTranslation
Description copied from interface:ITranslationStorageProvider.StorageGets the translation from storage.- Specified by:
getTranslationin interfaceITranslationStorageProvider.Storage- Parameters:
source- the source feature valuelanguage- the language- Returns:
- the translation
-
setTranslation
default void setTranslation(FeatureValue source, TranslateLanguage language, String translation, boolean autoSave) Description copied from interface:ITranslationStorageProvider.StorageSets the translation.- Specified by:
setTranslationin interfaceITranslationStorageProvider.Storage- Parameters:
source- the source feature valuelanguage- the languagetranslation- the translation
-
removeTranslation
Description copied from interface:ITranslationStorageProvider.StorageRemoves the translation from storage.- Specified by:
removeTranslationin interfaceITranslationStorageProvider.Storage- Parameters:
source- the source feature valuelanguage- the language
-
moveTranslation
default void moveTranslation(FeatureValue fromSource, FeatureValue toSource, TranslateLanguage language, boolean autoSave) Description copied from interface:ITranslationStorageProvider.StorageMove translation inside the storage from one key to enother.- Specified by:
moveTranslationin interfaceITranslationStorageProvider.Storage- Parameters:
fromSource- the source feature value to move fromtoSource- the source feature value to move tolanguage- the language
-
getTranslation
Gets the translation from the context storage.- Parameters:
key- the context translation key, cannot benull.language- the language, cannot benull.- Returns:
- the translation, can return
null.
-
setTranslation
void setTranslation(ContextTranslationKey key, TranslateLanguage language, String translation, boolean autoSave) Sets the translation of context storage.- Parameters:
key- the context translation key, cannot benull.language- the language, cannot benull.translation- the translation, can benull.autoSave- turns auto save feature on/off- Throws:
ModelValueAlreadyInUseException- if translation for model feature is already set for another key
-
removeTranslation
Removes the translation.- Parameters:
key- the context translation key, cannot benull.language- the language, cannot benull.autoSave- turns auto save feature on/of
-
saveFiles
Map<org.eclipse.core.resources.IFile,byte[]> saveFiles(Collection<ContextTranslationKey> affectedKeys, TranslateLanguage language, com.google.common.hash.HashFunction hashFunction) Saves affected translation files explicitly in case if translation data exist- Parameters:
translationFile- A file to save. Cannot benullhashFunction- Hash function to use during the export. May not benull- Returns:
- Hash code of saved file. May be
nullin case if no file is saved
-
moveTranslation
void moveTranslation(ContextTranslationKey fromKey, ContextTranslationKey toKey, TranslateLanguage language, boolean autoSave) Move translation from one key to another inside this single storage. Attantion! Implementation should move the comment of source translation key to new one.- Parameters:
fromKey- the from translation key, cannot benull.toKey- the to translation key, cannot benull.language- the language, cannot benull.
-
getComment
Gets the comment by the translation key.- Parameters:
key- the key, cannot benull.language- the language, cannot benull.- Returns:
- the comment, can return
null.
-
setComment
default void setComment(ContextTranslationKey key, TranslateLanguage language, String comment, boolean autoSave) Sets the comment for some translation key.- Parameters:
key- the context translation key, cannot benull.language- the language, cannot benull.comment- the comment, can benull.
-
removeComment
Removes the comment of the translation key.- Parameters:
key- the translation key, cannot benull.language- the language, cannot benull.
-
moveComment
default void moveComment(ContextTranslationKey fromKey, ContextTranslationKey toKey, TranslateLanguage language, boolean autoSave) Move only comment from one translation key to another. Note! The translation value of the source key will not move with it's comment.- Parameters:
fromKey- the from translation key, cannot benull.toKey- the to translation key, cannot benull.language- the language, cannot benull.
-
hasKeyForValue
boolean hasKeyForValue(String value, TranslateLanguage language, ContextTranslationKey skipTranslationKey) Checks that context storage has key for the value except the given skip key.- Parameters:
value- the value, cannot benull.language- the translate language, cannot benull.skipTranslationKey- the context key which need to skip in the check, can benull.- Returns:
- true, if context storage has key for the value
-