Class DesignerLocalizationManager
- java.lang.Object
-
- com.inductiveautomation.ignition.client.model.ClientLocalizationManager
-
- com.inductiveautomation.ignition.designer.i18n.DesignerLocalizationManager
-
- All Implemented Interfaces:
MutableTranslationPackage
,TranslationPackage
,java.io.Serializable
public class DesignerLocalizationManager extends ClientLocalizationManager implements MutableTranslationPackage
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PREVIEW_LOCALE
-
Fields inherited from class com.inductiveautomation.ignition.client.model.ClientLocalizationManager
_instance, EVENT_AVAILABLE_LOCALES, EVENT_TRANSLATIONS
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLocaleListener(LocaleListener listener)
void
addTerm(java.lang.String term)
Ensures that the specified key is in the translation package.void
addTranslation(java.lang.String key, java.util.Locale locale, java.lang.String value)
Sets a translation for the specified key and locale.void
addTranslations(java.lang.String key, TranslationMap translations)
Sets all of the translations for a specific key.protected boolean
areLocaleSetsDifferent(java.util.Collection<java.util.Locale> a, java.util.Collection<java.util.Locale> b)
boolean
areSettingsDefined(java.util.Locale locale)
TranslationPackageDiff
createDiff()
void
ensureLocaleExists(java.util.Locale locale)
Verifies that the locale is present, adding it if necessary.protected void
fireLocaleChanged()
static DesignerLocalizationManager
get()
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()
protected TranslationPackageDiff
getEdit()
KeyHashRule
getKeyHashRule()
The key hash rule dictates how term equivalency is calculated.java.util.Locale
getPreviewLocale()
java.util.Collection<RegionalSettings>
getRegionalSettings()
protected RegionalSettingsDiff
getSettingsEdit()
RegionalSettings
getSettingsFor(java.util.Locale locale)
Returns the settings for the locale.protected RegionalSettings
getSettingsFor(java.util.Locale locale, boolean strict)
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)
TranslationSettings
getTranslationSettings()
TranslationMap
getTranslationsFor(java.lang.String key)
protected boolean
hasChanges()
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
modifyRegionalSettings(RegionalSettings settings)
protected void
onEditStateChanged()
protected void
refreshModel()
boolean
removeKey(java.lang.String key)
Removes the specific key, and any translations.void
removeLocale(java.util.Locale locale)
void
removeLocaleListener(LocaleListener listener)
void
removeTranslation(java.lang.String key, java.util.Locale locale)
Removes a translation for a specified key and locale.void
resetLocale()
Resets the current locale to the base locale.protected void
saveChanges()
void
saveTranslationSettings(TranslationSettings settings)
void
setCurrentLocale(java.util.Locale locale)
void
setEnabled(boolean value)
Sets whether the localization manager should be used.protected void
setModel(TranslationPackage value)
void
setPreviewLocale(java.lang.String localeName)
protected void
setSettings(java.util.Collection<RegionalSettings> settings)
void
setup(DesignerContext context)
-
Methods inherited from class com.inductiveautomation.ignition.client.model.ClientLocalizationManager
addPropertyChangeListener, fireProperty, removePropertyChangeListener, set
-
-
-
-
Field Detail
-
PREVIEW_LOCALE
public static final java.lang.String PREVIEW_LOCALE
- See Also:
- Constant Field Values
-
-
Method Detail
-
get
public static DesignerLocalizationManager get()
-
isTranslationEnabled
public boolean isTranslationEnabled()
- Specified by:
isTranslationEnabled
in classClientLocalizationManager
-
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.
-
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.
-
getString
public java.lang.String getString(java.lang.String key)
- Specified by:
getString
in classClientLocalizationManager
-
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.
-
getCurrentLocale
public java.util.Locale getCurrentLocale()
- Specified by:
getCurrentLocale
in classClientLocalizationManager
-
setCurrentLocale
public void setCurrentLocale(java.util.Locale locale)
- Specified by:
setCurrentLocale
in classClientLocalizationManager
-
addLocaleListener
public void addLocaleListener(LocaleListener listener)
- Specified by:
addLocaleListener
in classClientLocalizationManager
-
removeLocaleListener
public void removeLocaleListener(LocaleListener listener)
- Specified by:
removeLocaleListener
in classClientLocalizationManager
-
resetLocale
public void resetLocale()
Description copied from class:ClientLocalizationManager
Resets the current locale to the base locale. *- Specified by:
resetLocale
in 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
public void setup(DesignerContext context)
-
refreshModel
protected void refreshModel()
-
setModel
protected void setModel(TranslationPackage value)
-
setSettings
protected void setSettings(java.util.Collection<RegionalSettings> settings)
-
getEdit
protected TranslationPackageDiff getEdit()
-
getSettingsEdit
protected RegionalSettingsDiff getSettingsEdit()
-
hasChanges
protected boolean hasChanges()
-
addTerm
public void addTerm(java.lang.String term)
Description copied from interface:MutableTranslationPackage
Ensures that the specified key is in the translation package.- Specified by:
addTerm
in interfaceMutableTranslationPackage
-
addTranslation
public void addTranslation(java.lang.String key, java.util.Locale locale, java.lang.String value)
Description copied from interface:MutableTranslationPackage
Sets a translation for the specified key and locale.- Specified by:
addTranslation
in interfaceMutableTranslationPackage
-
removeTranslation
public void removeTranslation(java.lang.String key, java.util.Locale locale)
Description copied from interface:MutableTranslationPackage
Removes a translation for a specified key and locale. Used when someone had a translation and blanks it out.- Specified by:
removeTranslation
in interfaceMutableTranslationPackage
-
addTranslations
public void addTranslations(java.lang.String key, TranslationMap translations)
Description copied from interface:MutableTranslationPackage
Sets 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:
addTranslations
in interfaceMutableTranslationPackage
-
removeKey
public boolean removeKey(java.lang.String key)
Description copied from interface:MutableTranslationPackage
Removes the specific key, and any translations.- Specified by:
removeKey
in interfaceMutableTranslationPackage
- Returns:
- true if key was present
-
ensureLocaleExists
public void ensureLocaleExists(java.util.Locale locale)
Description copied from interface:MutableTranslationPackage
Verifies that the locale is present, adding it if necessary.- Specified by:
ensureLocaleExists
in interfaceMutableTranslationPackage
-
removeLocale
public void removeLocale(java.util.Locale locale)
- Specified by:
removeLocale
in interfaceMutableTranslationPackage
-
getBaseLocale
public java.util.Locale getBaseLocale()
- Specified by:
getBaseLocale
in interfaceTranslationPackage
- 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.- Specified by:
getKeyHashRule
in interfaceTranslationPackage
-
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.- Specified by:
isDefined
in interfaceTranslationPackage
-
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.- Specified by:
isDefined
in interfaceTranslationPackage
-
getAvailableKeys
public java.util.Collection<java.lang.String> getAvailableKeys()
- Specified by:
getAvailableKeys
in interfaceTranslationPackage
- Returns:
- all of the defined keys.
-
createDiff
public TranslationPackageDiff createDiff()
- Specified by:
createDiff
in interfaceTranslationPackage
- Returns:
- an empty, modifiable diff that respects the same rules as the translation package.
-
getAllTranslations
public java.util.Iterator<Translation> getAllTranslations()
- Specified by:
getAllTranslations
in interfaceTranslationPackage
- Returns:
- an iterator that goes through all of the translations. Does not include defined keys that have no translations.
-
getSettingsFor
public RegionalSettings getSettingsFor(java.util.Locale locale)
Returns the settings for the locale. If necessary, will create default settings to return. Therefore, do not use this to see if settings are defined.
-
getSettingsFor
protected RegionalSettings getSettingsFor(java.util.Locale locale, boolean strict)
-
areSettingsDefined
public boolean areSettingsDefined(java.util.Locale locale)
-
getRegionalSettings
public java.util.Collection<RegionalSettings> getRegionalSettings()
-
modifyRegionalSettings
public void modifyRegionalSettings(RegionalSettings settings)
-
getTranslationSettings
public TranslationSettings getTranslationSettings()
-
saveTranslationSettings
public void saveTranslationSettings(TranslationSettings settings)
-
getPreviewLocale
public java.util.Locale getPreviewLocale()
- Specified by:
getPreviewLocale
in classClientLocalizationManager
-
setPreviewLocale
public void setPreviewLocale(java.lang.String localeName)
-
fireLocaleChanged
protected void fireLocaleChanged()
-
onEditStateChanged
protected void onEditStateChanged()
-
areLocaleSetsDifferent
protected boolean areLocaleSetsDifferent(java.util.Collection<java.util.Locale> a, java.util.Collection<java.util.Locale> b)
-
saveChanges
protected void saveChanges()
-
-