Class DesignerLocalizationManager
java.lang.Object
com.inductiveautomation.ignition.client.model.ClientLocalizationManager
com.inductiveautomation.ignition.designer.i18n.DesignerLocalizationManager
- All Implemented Interfaces:
MutableTranslationPackage, TranslationPackage
public class DesignerLocalizationManager
extends ClientLocalizationManager
implements MutableTranslationPackage
-
Field Summary
FieldsFields inherited from class ClientLocalizationManager
_instance, EVENT_AVAILABLE_LOCALES, EVENT_TRANSLATIONSFields inherited from interface TranslationPackage
BASE_LOCALE, NOTES_IDENTIFIER -
Method Summary
Modifier and TypeMethodDescriptionvoidEnsures that the specified key is in the translation package.voidaddLocaleListener(LocaleListener listener) voidaddTranslation(@NonNull String key, @NonNull Locale locale, @NonNull String value) Sets a translation for the specified key and locale.voidaddTranslations(@NonNull String key, TranslationMap translations) Sets all of the translations for a specific key.voidapplyLocalDiff(@NonNull TranslationPackageDiff diff) Applies a diff to the local in-memory cache immediately, firing the same change events (ClientLocalizationManager.EVENT_TRANSLATIONS,ClientLocalizationManager.EVENT_AVAILABLE_LOCALES) that an incomingLocalizationMessages.TRANSLATION_UPDATEpush would.@NonNull TranslationPackageDiffCreates an empty, modifiable diff that respects the same rules as this translation package.voidensureLocaleExists(@NonNull Locale locale) Verifies that the locale is present, adding it if necessary.protected voidvoidSynchronously commits any pending local edits (the coalesced diff) to the gateway, leaving no uncommitted diff behind.static DesignerLocalizationManagerget()@NonNull StringTranslates the given key into the requested locale.@NonNull Collection<String> @NonNull Collection<Locale> protected TranslationPackageDiffgetEdit()@NonNull KeyHashRuleThe key hash rule dictates how key equivalency is calculated.@Nullable StringReturns the editorial note associated with the given key, ornullif there is none.getNotes()Translates the given key into the requested locale, returning null if no translation exists.getStringForBundleKey(String bundlekey) getTranslationsFor(@NonNull String key) protected booleanbooleanbooleanReturns whether the key is defined in the package.booleanReturns whether there is a translation defined for the given key in the given locale.booleanprotected voidprotected voidbooleanRemoves the specific key, and any translations.voidremoveLocale(@NonNull Locale locale) voidremoveLocaleListener(LocaleListener listener) voidremoveTranslation(@NonNull String key, @NonNull Locale locale) Removes a translation for a specified key and locale.voidResets the current locale to the base locale.protected voidCaptures the pending diff (if any), detaches it so further edits accumulate in a fresh diff, and hands the blocking gateway send tosaveQueue.voidsaveTranslationSettings(TranslationSettings settings) voidsetCurrentLocale(Locale locale) voidsetEnabled(boolean value) Sets whether the localization manager should be used.protected voidsetModel(TranslationPackage value) voidSets or clears the editorial note for the given key.voidsetPreviewLocale(String localeName) voidsetup(DesignerContext context) Methods inherited from class ClientLocalizationManager
addPropertyChangeListener, fireProperty, removePropertyChangeListener, setMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TranslationPackage
getResolvedTranslations
-
Field Details
-
PREVIEW_LOCALE
- See Also:
-
-
Method Details
-
get
-
applyLocalDiff
Description copied from class:ClientLocalizationManagerApplies a diff to the local in-memory cache immediately, firing the same change events (ClientLocalizationManager.EVENT_TRANSLATIONS,ClientLocalizationManager.EVENT_AVAILABLE_LOCALES) that an incomingLocalizationMessages.TRANSLATION_UPDATEpush would. Lets a local writer make its edit visible to subsequent reads without waiting for the gateway round-trip and the asynchronous push that follows. Re-applying the same diff when that push later arrives is idempotent.- Specified by:
applyLocalDiffin classClientLocalizationManager
-
isTranslationEnabled
public boolean isTranslationEnabled()- Specified by:
isTranslationEnabledin classClientLocalizationManager
-
getAvailableLocales
- Specified by:
getAvailableLocalesin interfaceTranslationPackage- Specified by:
getAvailableLocalesin classClientLocalizationManager- Returns:
- the locales for which translations are available. This always includes
TranslationPackage.BASE_LOCALE, the language in which keys are defined.
-
get
Description copied from interface:TranslationPackageTranslates the given key into the requested locale.- Specified by:
getin interfaceTranslationPackage- Specified by:
getin classClientLocalizationManager- Parameters:
locale- the locale to find a match forkey- the key to find a match for- Returns:
- the translation of the key for the requested locale, or the key itself if no translation is available.
-
getString
- Specified by:
getStringin classClientLocalizationManager
-
getStrict
- Specified by:
getStrictin classClientLocalizationManager
-
getStrict
Description copied from interface:TranslationPackageTranslates the given key into the requested locale, returning null if no translation exists.- Specified by:
getStrictin interfaceTranslationPackage- Specified by:
getStrictin classClientLocalizationManager- Parameters:
locale- the locale to find a value forkey- the key to find a match for- Returns:
- the translation, or null if the translation doesn't exist.
-
getStringForBundleKey
- Specified by:
getStringForBundleKeyin classClientLocalizationManager
-
getTranslationsFor
- Specified by:
getTranslationsForin interfaceTranslationPackage- Specified by:
getTranslationsForin classClientLocalizationManager- Returns:
- a map of all the translations available for a given key.
-
getCurrentLocale
- Specified by:
getCurrentLocalein classClientLocalizationManager
-
setCurrentLocale
- Specified by:
setCurrentLocalein classClientLocalizationManager
-
addLocaleListener
- Specified by:
addLocaleListenerin classClientLocalizationManager
-
removeLocaleListener
- Specified by:
removeLocaleListenerin classClientLocalizationManager
-
resetLocale
public void resetLocale()Description copied from class:ClientLocalizationManagerResets the current locale to the base locale. *- Specified by:
resetLocalein classClientLocalizationManager
-
setEnabled
public void setEnabled(boolean value) Sets whether the localization manager should be used. If false, returns translations as if the current locale was the default locale. However, doesn't fire events like setting the locale. Used especially to save projects. -
setup
-
refreshModel
protected void refreshModel() -
setModel
-
getEdit
-
hasChanges
protected boolean hasChanges() -
hasPendingChanges
public boolean hasPendingChanges()- Returns:
- whether there are uncommitted local translation edits awaiting the coalesced save.
-
flushPendingChanges
public void flushPendingChanges()Synchronously commits any pending local edits (the coalesced diff) to the gateway, leaving no uncommitted diff behind. Callers should invoke this before operations that rebuild the translation package under a new key-hash rule (e.g.saveTranslationSettings(TranslationSettings)), so that a diff built against the old rule is never flushed onto a model rebuilt under the new one. A no-op when there are no pending changes. -
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- Parameters:
term- The key to add.
-
addTranslation
Description copied from interface:MutableTranslationPackageSets a translation for the specified key and locale.- Specified by:
addTranslationin interfaceMutableTranslationPackage- Parameters:
key- The key to translate.locale- The target locale.value- The translated string.
-
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- Parameters:
key- The key to modify.locale- The locale for which to remove the translation.
-
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
-
removeKey
Description copied from interface:MutableTranslationPackageRemoves the specific key, and any translations.- Specified by:
removeKeyin interfaceMutableTranslationPackage- Returns:
- true if key was present
-
ensureLocaleExists
Description copied from interface:MutableTranslationPackageVerifies that the locale is present, adding it if necessary.- Specified by:
ensureLocaleExistsin interfaceMutableTranslationPackage
-
removeLocale
- Specified by:
removeLocalein interfaceMutableTranslationPackage
-
getKeyHashRule
Description copied from interface:TranslationPackageThe key hash rule dictates how key equivalency is calculated. Though this field should not be used to look up keys, it's important that derived translation packages use the same rule.- Specified by:
getKeyHashRulein interfaceTranslationPackage
-
isDefined
Description copied from interface:TranslationPackageReturns whether the key is defined in the package. A key can be defined without any particular translations.- Specified by:
isDefinedin interfaceTranslationPackage
-
isDefined
Description copied from interface:TranslationPackageReturns whether there is a translation defined for the given key in the given locale.- Specified by:
isDefinedin interfaceTranslationPackage
-
getAvailableKeys
- Specified by:
getAvailableKeysin interfaceTranslationPackage- Returns:
- all the defined keys.
-
createDiff
Description copied from interface:TranslationPackageCreates an empty, modifiable diff that respects the same rules as this translation package. A diff is used to track changes relative to this package.- Specified by:
createDiffin interfaceTranslationPackage- Returns:
- a new
TranslationPackageDiff.
-
getAllTranslations
- Specified by:
getAllTranslationsin interfaceTranslationPackage- Returns:
- an iterator that goes through all the translations. Does not include defined keys that have no translations.
-
getTranslationSettings
-
saveTranslationSettings
-
getPreviewLocale
- Specified by:
getPreviewLocalein classClientLocalizationManager
-
setPreviewLocale
-
getNote
Description copied from interface:TranslationPackageReturns the editorial note associated with the given key, ornullif there is none. Notes are per-key metadata keyed by the raw key string.- Specified by:
getNotein interfaceTranslationPackage
-
getNotes
- Specified by:
getNotesin interfaceTranslationPackage- Returns:
- an unmodifiable view of all notes, keyed by the raw key string. Never null; may be empty.
-
setNote
Description copied from interface:MutableTranslationPackageSets or clears the editorial note for the given key. A null or blank note clears any existing note.- Specified by:
setNotein interfaceMutableTranslationPackage- Parameters:
key- The key the note applies to.note- The note text, or null/blank to clear.
-
fireLocaleChanged
protected void fireLocaleChanged() -
onEditStateChanged
protected void onEditStateChanged() -
saveChanges
protected void saveChanges()Captures the pending diff (if any), detaches it so further edits accumulate in a fresh diff, and hands the blocking gateway send tosaveQueue. Safe to call from the EDT (the coalesced auto-save path) or fromflushPendingChanges()— no RPC ormodelLockis held across the network call.
-