Class ClientLocalizationManagerImpl
java.lang.Object
com.inductiveautomation.ignition.client.model.ClientLocalizationManager
com.inductiveautomation.factorypmi.application.i18n.ClientLocalizationManagerImpl
- All Implemented Interfaces:
TranslationPackage
-
Field Summary
Fields inherited from class ClientLocalizationManager
_instance, EVENT_AVAILABLE_LOCALES, EVENT_TRANSLATIONSFields inherited from interface TranslationPackage
BASE_LOCALE, NOTES_IDENTIFIER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLocaleListener(LocaleListener listener) 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.protected void@NonNull StringTranslates the given key into the requested locale.@NonNull Collection<Locale> The 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) @Nullable TranslationMapgetTranslationsFor(@NonNull String key) voidbooleanReturns whether the key is defined in the package.booleanReturns whether there is a translation defined for the given key in the given locale.booleanvoidloadTranslationDatabase(File location) This functions loads the term db from a file, which should be a serialized TranslationPackage.voidremoveLocaleListener(LocaleListener listener) voidResets the current locale to the base locale.voidsetCurrentLocale(Locale locale) Methods inherited from class ClientLocalizationManager
addPropertyChangeListener, fireProperty, get, removePropertyChangeListener, setMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TranslationPackage
getResolvedTranslations
-
Constructor Details
-
ClientLocalizationManagerImpl
-
-
Method Details
-
initNotificationListeners
public void initNotificationListeners() -
loadTranslationDatabase
This functions loads the term db from a file, which should be a serialized TranslationPackage. -
isTranslationEnabled
public boolean isTranslationEnabled()- Specified by:
isTranslationEnabledin classClientLocalizationManager
-
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. -
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.
-
isDefined
Description copied from interface:TranslationPackageReturns whether the key is defined in the package. A key can be defined without any particular translations. -
isDefined
Description copied from interface:TranslationPackageReturns whether there is a translation defined for the given key in the given locale. -
getCurrentLocale
- Specified by:
getCurrentLocalein classClientLocalizationManager
-
setCurrentLocale
- Specified by:
setCurrentLocalein classClientLocalizationManager
-
getPreviewLocale
- Specified by:
getPreviewLocalein classClientLocalizationManager
-
resetLocale
public void resetLocale()Description copied from class:ClientLocalizationManagerResets the current locale to the base locale. *- Specified by:
resetLocalein classClientLocalizationManager
-
getString
- Specified by:
getStringin classClientLocalizationManager
-
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.
-
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.
-
getAvailableKeys
- Returns:
- all the defined keys.
-
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. -
getNotes
-
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.- Returns:
- a new
TranslationPackageDiff.
-
getAllTranslations
- Returns:
- an iterator that goes through all the translations. Does not include defined keys that have no translations.
-
addLocaleListener
- Specified by:
addLocaleListenerin classClientLocalizationManager
-
removeLocaleListener
- Specified by:
removeLocaleListenerin classClientLocalizationManager
-
fireLocaleChanged
protected void fireLocaleChanged() -
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
-