Class ClientLocalizationManagerImpl
- java.lang.Object
-
- com.inductiveautomation.ignition.client.model.ClientLocalizationManager
-
- com.inductiveautomation.factorypmi.application.i18n.ClientLocalizationManagerImpl
-
- All Implemented Interfaces:
TranslationPackage
,java.io.Serializable
public class ClientLocalizationManagerImpl extends ClientLocalizationManager
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.inductiveautomation.ignition.client.model.ClientLocalizationManager
_instance, EVENT_AVAILABLE_LOCALES, EVENT_TRANSLATIONS
-
-
Constructor Summary
Constructors Constructor Description ClientLocalizationManagerImpl(ClientContextImpl context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLocaleListener(LocaleListener listener)
TranslationPackageDiff
createDiff()
protected void
fireLocaleChanged()
java.lang.String
get(java.util.Locale locale, java.lang.String key)
java.util.Iterator<Translation>
getAllTranslations()
java.util.Collection<java.lang.String>
getAvailableKeys()
java.util.Collection<java.util.Locale>
getAvailableLocales()
java.util.Locale
getBaseLocale()
java.util.Locale
getCurrentLocale()
KeyHashRule
getKeyHashRule()
The key hash rule dictates how term equivalency is calculated.java.util.Locale
getPreviewLocale()
java.lang.String
getStrict(java.lang.String key)
java.lang.String
getStrict(java.util.Locale locale, java.lang.String key)
java.lang.String
getString(java.lang.String key)
java.lang.String
getStringForBundleKey(java.lang.String bundlekey)
TranslationMap
getTranslationsFor(java.lang.String key)
void
initNotificationListener()
boolean
isDefined(java.lang.String key)
Returns whether the key is defined in the package.boolean
isDefined(java.lang.String key, java.util.Locale l)
Returns whether there is a translation defined for the given key in the given locale.boolean
isTranslationEnabled()
void
loadTranslationDatabase(java.io.File location)
This functions loads the term db from a file, which should be a serialized TranslationPackage.void
removeLocaleListener(LocaleListener listener)
void
resetLocale()
Resets the current locale to the base locale.void
setCurrentLocale(java.util.Locale locale)
-
Methods inherited from class com.inductiveautomation.ignition.client.model.ClientLocalizationManager
addPropertyChangeListener, fireProperty, get, removePropertyChangeListener, set
-
-
-
-
Constructor Detail
-
ClientLocalizationManagerImpl
public ClientLocalizationManagerImpl(ClientContextImpl context)
-
-
Method Detail
-
initNotificationListener
public void initNotificationListener()
-
loadTranslationDatabase
public void loadTranslationDatabase(java.io.File location)
This functions loads the term db from a file, which should be a serialized TranslationPackage.
-
isTranslationEnabled
public boolean isTranslationEnabled()
- Specified by:
isTranslationEnabled
in classClientLocalizationManager
-
getBaseLocale
public java.util.Locale getBaseLocale()
- Returns:
- the "base" locale, the language in which the terms are defined.
-
getKeyHashRule
public KeyHashRule getKeyHashRule()
Description copied from interface:TranslationPackage
The key hash rule dictates how term equivalency is calculated. Though this field should not be used to look up terms, it's important that derived translation packages use the same rule.
-
getAvailableLocales
public java.util.Collection<java.util.Locale> getAvailableLocales()
- Specified by:
getAvailableLocales
in interfaceTranslationPackage
- Specified by:
getAvailableLocales
in classClientLocalizationManager
- Returns:
- the locales for which translations are available. This will include the base locale.
-
isDefined
public boolean isDefined(java.lang.String key)
Description copied from interface:TranslationPackage
Returns whether the key is defined in the package. A key can be defined without any particular translations.
-
isDefined
public boolean isDefined(java.lang.String key, java.util.Locale l)
Description copied from interface:TranslationPackage
Returns whether there is a translation defined for the given key in the given locale.
-
getCurrentLocale
public java.util.Locale getCurrentLocale()
- Specified by:
getCurrentLocale
in classClientLocalizationManager
-
setCurrentLocale
public void setCurrentLocale(java.util.Locale locale)
- Specified by:
setCurrentLocale
in classClientLocalizationManager
-
getPreviewLocale
public java.util.Locale getPreviewLocale()
- Specified by:
getPreviewLocale
in classClientLocalizationManager
-
resetLocale
public void resetLocale()
Description copied from class:ClientLocalizationManager
Resets the current locale to the base locale. *- Specified by:
resetLocale
in classClientLocalizationManager
-
getString
public java.lang.String getString(java.lang.String key)
- Specified by:
getString
in classClientLocalizationManager
-
get
public java.lang.String get(java.util.Locale locale, java.lang.String key)
- Specified by:
get
in interfaceTranslationPackage
- Specified by:
get
in classClientLocalizationManager
key
- the key to find a match for, or return value if no value found- Returns:
- the translation of the key for the requested locale, or the key, if the translation is not available.
-
getStrict
public java.lang.String getStrict(java.lang.String key)
- Specified by:
getStrict
in classClientLocalizationManager
-
getStrict
public java.lang.String getStrict(java.util.Locale locale, java.lang.String key)
- Specified by:
getStrict
in interfaceTranslationPackage
- Specified by:
getStrict
in 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
public java.lang.String getStringForBundleKey(java.lang.String bundlekey)
- Specified by:
getStringForBundleKey
in classClientLocalizationManager
-
getTranslationsFor
public TranslationMap getTranslationsFor(java.lang.String key)
- Specified by:
getTranslationsFor
in interfaceTranslationPackage
- Specified by:
getTranslationsFor
in classClientLocalizationManager
- Returns:
- a map of all of the translations available for a given key.
-
getAvailableKeys
public java.util.Collection<java.lang.String> getAvailableKeys()
- Returns:
- all of the defined keys.
-
createDiff
public TranslationPackageDiff createDiff()
- Returns:
- an empty, modifiable diff that respects the same rules as the translation package.
-
getAllTranslations
public java.util.Iterator<Translation> getAllTranslations()
- Returns:
- an iterator that goes through all of the translations. Does not include defined keys that have no translations.
-
addLocaleListener
public void addLocaleListener(LocaleListener listener)
- Specified by:
addLocaleListener
in classClientLocalizationManager
-
removeLocaleListener
public void removeLocaleListener(LocaleListener listener)
- Specified by:
removeLocaleListener
in classClientLocalizationManager
-
fireLocaleChanged
protected void fireLocaleChanged()
-
-