Class TranslationPackageDiff
java.lang.Object
com.inductiveautomation.ignition.common.i18n.translation.BasicTranslationPackage
com.inductiveautomation.ignition.common.i18n.translation.TranslationPackageDiff
- All Implemented Interfaces:
MutableTranslationPackage, TranslationPackage, Iterable<Translation>
public class TranslationPackageDiff
extends BasicTranslationPackage
implements Iterable<Translation>
A specialized translation package that tracks added, modified, and removed keys and translations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic final record -
Field Summary
FieldsFields inherited from class BasicTranslationPackage
bundles, hashRule, index, notesFields inherited from interface TranslationPackage
BASE_LOCALE, NOTES_IDENTIFIER -
Constructor Summary
ConstructorsConstructorDescriptionTranslationPackageDiff(KeyHashRule hashRule) TranslationPackageDiff(TranslationPackage initial, TranslationPackage updated) -
Method Summary
Modifier and TypeMethodDescriptionvoidEnsures that the specified key is in the translation package.voidaddTranslation(String key, Locale locale, @Nullable String value) Sets a translation for the specified key and locale.voidaddTranslations(String key, @Nullable TranslationMap translations) Sets all of the translations for a specific key.voidclearChanges(Locale locale) Removes any modified keys for the given locale.voidensureLocaleExists(Locale locale) Verifies that the locale is present, adding it if necessary.Returns an unmodifiable set of the removed keys *booleanbooleanisModified(String key) booleanisModified(String key, Locale locale) booleanbooleanbooleanisTranslationRemoved(String key, Locale locale) Whether this diff staged a removal of the translation forkeyinlocale.iterator()protected @Nullable HashedKeyregisterIndexKey(String key) booleanRemoves the specific key, and any translations.voidremoveLocale(Locale locale) voidremoveTranslation(String key, Locale locale) Removes a translation for a specified key and locale.voidRecords a note change in the diff.Methods inherited from class BasicTranslationPackage
addTerm, applyPackage, createDiff, equals, get, getAllTranslations, getAvailableKeys, getAvailableLocales, getBundle, getHashedKey, getIndex, getKeyHashRule, getNote, getNotes, getOrCreateBundle, getOrCreateHashedKey, getOrNull, getStrict, getTranslationsFor, hashKey, isDefined, isDefined, setIndex, setKeyHashRule, updateIndexMethods inherited from class Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface TranslationPackage
getResolvedTranslations
-
Field Details
-
removedKeys
-
removedLocales
-
removedTranslations
-
removedNotes
-
-
Constructor Details
-
TranslationPackageDiff
public TranslationPackageDiff() -
TranslationPackageDiff
-
TranslationPackageDiff
-
-
Method Details
-
getRemovedKeys
-
getRemovedLocales
-
addKey
Description copied from interface:MutableTranslationPackageEnsures that the specified key is in the translation package. This registers a key without necessarily providing a translation immediately.- Specified by:
addKeyin interfaceMutableTranslationPackage- Overrides:
addKeyin classBasicTranslationPackage- Parameters:
key- The key to add.
-
isModified
-
isModified
-
isRemoved
-
isRemoved
-
isTranslationRemoved
-
clearChanges
Removes any modified keys for the given locale. Does not mark the locale as deleted. * -
registerIndexKey
-
addTranslation
Description copied from interface:MutableTranslationPackageSets a translation for the specified key and locale.- Specified by:
addTranslationin interfaceMutableTranslationPackage- Overrides:
addTranslationin classBasicTranslationPackage- Parameters:
key- The key to translate.locale- The target locale.value- The translated string.
-
addTranslations
Description copied from interface:MutableTranslationPackageSets all of the translations for a specific key. Translation map can be null, in which case the key will simply be registered in the index.- Specified by:
addTranslationsin interfaceMutableTranslationPackage- Overrides:
addTranslationsin classBasicTranslationPackage
-
removeTranslation
Description copied from interface:MutableTranslationPackageRemoves a translation for a specified key and locale. Used when someone had a translation and blanks it out. This removes the specific translation but keeps the key in the package.- Specified by:
removeTranslationin interfaceMutableTranslationPackage- Overrides:
removeTranslationin classBasicTranslationPackage- Parameters:
key- The key to modify.locale- The locale for which to remove the translation.
-
removeKey
Description copied from interface:MutableTranslationPackageRemoves the specific key, and any translations.- Specified by:
removeKeyin interfaceMutableTranslationPackage- Overrides:
removeKeyin classBasicTranslationPackage- Returns:
- true if key was present
-
setNote
Records a note change in the diff. A non-blank note is staged as a modification; a null/blank note marks the note for removal. Mirrors howremoveKey(String)/removeTranslation(String, Locale)move entries between the staged and removed collections.- Specified by:
setNotein interfaceMutableTranslationPackage- Overrides:
setNotein classBasicTranslationPackage- Parameters:
key- The key the note applies to.note- The note text, or null/blank to clear.
-
getModifiedNotes
-
getRemovedNotes
-
ensureLocaleExists
Description copied from interface:MutableTranslationPackageVerifies that the locale is present, adding it if necessary.- Specified by:
ensureLocaleExistsin interfaceMutableTranslationPackage- Overrides:
ensureLocaleExistsin classBasicTranslationPackage
-
removeLocale
- Specified by:
removeLocalein interfaceMutableTranslationPackage- Overrides:
removeLocalein classBasicTranslationPackage
-
hasChanges
public boolean hasChanges()- Returns:
- True if there are any removals, additions, or modifications in this diff.
-
iterator
- Specified by:
iteratorin interfaceIterable<Translation>
-
getRemovedTranslations
-