Class DelegateTranslationPackage
- java.lang.Object
-
- com.inductiveautomation.ignition.common.i18n.translation.DelegateTranslationPackage
-
- All Implemented Interfaces:
MutableTranslationPackage,TranslationPackage,java.io.Serializable
public class DelegateTranslationPackage extends java.lang.Object implements MutableTranslationPackage
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DelegateTranslationPackage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTerm(java.lang.String key)Ensures that the specified key is in the translation package.voidaddTranslation(java.lang.String key, java.util.Locale locale, java.lang.String value)Sets a translation for the specified key and locale.voidaddTranslations(java.lang.String key, TranslationMap translations)Sets all of the translations for a specific key.TranslationPackageDiffcreateDiff()voidensureLocaleExists(java.util.Locale locale)Verifies that the locale is present, adding it if necessary.java.lang.Stringget(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.LocalegetBaseLocale()KeyHashRulegetKeyHashRule()The key hash rule dictates how term equivalency is calculated.java.lang.StringgetStrict(java.util.Locale locale, java.lang.String key)TranslationMapgetTranslationsFor(java.lang.String key)booleanisDefined(java.lang.String key)Returns whether the key is defined in the package.booleanisDefined(java.lang.String key, java.util.Locale l)Returns whether there is a translation defined for the given key in the given locale.booleanremoveKey(java.lang.String key)Removes the specific key, and any translations.voidremoveLocale(java.util.Locale locale)voidremoveTranslation(java.lang.String key, java.util.Locale locale)Removes a translation for a specified key and locale.voidsetDelegatePackage(MutableTranslationPackage value)
-
-
-
Method Detail
-
setDelegatePackage
public void setDelegatePackage(MutableTranslationPackage value)
-
getKeyHashRule
public KeyHashRule getKeyHashRule()
Description copied from interface:TranslationPackageThe 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:
getKeyHashRulein interfaceTranslationPackage
-
addTerm
public void addTerm(java.lang.String key)
Description copied from interface:MutableTranslationPackageEnsures that the specified key is in the translation package.- Specified by:
addTermin interfaceMutableTranslationPackage
-
addTranslation
public void addTranslation(java.lang.String key, java.util.Locale locale, java.lang.String value)Description copied from interface:MutableTranslationPackageSets a translation for the specified key and locale.- Specified by:
addTranslationin interfaceMutableTranslationPackage
-
removeTranslation
public void removeTranslation(java.lang.String key, java.util.Locale locale)Description copied from interface:MutableTranslationPackageRemoves a translation for a specified key and locale. Used when someone had a translation and blanks it out.- Specified by:
removeTranslationin interfaceMutableTranslationPackage
-
getBaseLocale
public java.util.Locale getBaseLocale()
- Specified by:
getBaseLocalein interfaceTranslationPackage- Returns:
- the "base" locale, the language in which the terms are defined.
-
addTranslations
public void addTranslations(java.lang.String key, TranslationMap translations)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
-
getAvailableLocales
public java.util.Collection<java.util.Locale> getAvailableLocales()
- Specified by:
getAvailableLocalesin interfaceTranslationPackage- 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:TranslationPackageReturns whether the key is defined in the package. A key can be defined without any particular translations.- Specified by:
isDefinedin interfaceTranslationPackage
-
removeKey
public boolean removeKey(java.lang.String key)
Description copied from interface:MutableTranslationPackageRemoves the specific key, and any translations.- Specified by:
removeKeyin interfaceMutableTranslationPackage- Returns:
- true if key was present
-
isDefined
public boolean isDefined(java.lang.String key, java.util.Locale l)Description copied from interface:TranslationPackageReturns whether there is a translation defined for the given key in the given locale.- Specified by:
isDefinedin interfaceTranslationPackage
-
ensureLocaleExists
public void ensureLocaleExists(java.util.Locale locale)
Description copied from interface:MutableTranslationPackageVerifies that the locale is present, adding it if necessary.- Specified by:
ensureLocaleExistsin interfaceMutableTranslationPackage
-
removeLocale
public void removeLocale(java.util.Locale locale)
- Specified by:
removeLocalein interfaceMutableTranslationPackage
-
get
public java.lang.String get(java.util.Locale locale, java.lang.String key)- Specified by:
getin interfaceTranslationPackagekey- 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.util.Locale locale, java.lang.String key)- Specified by:
getStrictin interfaceTranslationPackage- 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.
-
getTranslationsFor
public TranslationMap getTranslationsFor(java.lang.String key)
- Specified by:
getTranslationsForin interfaceTranslationPackage- Returns:
- a map of all of the translations available for a given key.
-
getAvailableKeys
public java.util.Collection<java.lang.String> getAvailableKeys()
- Specified by:
getAvailableKeysin interfaceTranslationPackage- Returns:
- all of the defined keys.
-
createDiff
public TranslationPackageDiff createDiff()
- Specified by:
createDiffin interfaceTranslationPackage- Returns:
- an empty, modifiable diff that respects the same rules as the translation package.
-
getAllTranslations
public java.util.Iterator<Translation> getAllTranslations()
- Specified by:
getAllTranslationsin interfaceTranslationPackage- Returns:
- an iterator that goes through all of the translations. Does not include defined keys that have no translations.
-
-