Package VASSAL.i18n
Class ComponentI18nData
java.lang.Object
VASSAL.i18n.ComponentI18nData
public class ComponentI18nData extends Object
Object encapsulating the internationalization information for a component.
The majority of translatable components subclass AbstractConfigurable,
but some extend JFrame or JDialog and implement Configurable or
AutoConfigurable.
AbstractConfigurable components are almost completely handled within the
AbstractConfigurable base class. AutoConfigurable/Configurable components
must call a different constructor and supply additional information.
- Author:
- Brent Easton
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classComponentI18nData.PropertyAn attribute of a Configurable component that can be translated into another language -
Field Summary
Fields Modifier and Type Field Description protected Map<String,ComponentI18nData.Property>allPropertiesprotected List<Translatable>childrenprotected ConfigurablemyComponentprotected Translatableparentprotected Stringprefixprotected Map<String,ComponentI18nData.Property>translatableProperties -
Constructor Summary
Constructors Constructor Description ComponentI18nData(AbstractConfigurable c, String prefix)Build from an AbstractConfigurable.ComponentI18nData(AbstractConfigurable c, String prefix, ArrayList<String> names, ArrayList<Class<?>> types, ArrayList<String> descriptions)ComponentI18nData(AutoConfigurable c, String prefix)Build from an AutoConfigurableComponentI18nData(Configurable c, String prefix)ComponentI18nData(Configurable c, String prefix, Translatable parent)ComponentI18nData(Configurable c, String prefix, Translatable parent, String[] names, boolean[] translatable, String[] descriptions)Build from a Configurable.ComponentI18nData(Configurable c, GamePiece piece)Special build for PrototypeDefinition and PieceSlot -
Method Summary
Modifier and Type Method Description voidapplyTranslation(String attr, String value)Apply a translatation to the specified attribute.StringgetAttributeDescription(String attr)Return description for named AttributeCollection<String>getAttributeKeys()Return a list of all of the translatable Keys for attributes of this Translatable item.List<Translatable>getChildren()Return all child Translatable components of this componentStringgetFullPrefix()Return a unique key prefix including a full path of parent prefixes.StringgetLocalUntranslatedValue(String attr)Return the pre-translation value stored in this Object.TranslatablegetOwningComponent()Return the owning Translatable of this componentStringgetPrefix()Return a unique Key prefix identifying this componentStringgetTranslatedValue(String attr, Translation translation)booleanhasUntranslatedAttributes(Translation t)Return true if this component or any of its children have at least one translatable attribute with a non-null value that does not have a translation in the supplied translation.protected voidinit(Configurable c, String pfx, String[] names, Class<?>[] types, String[] descriptions)protected voidinit(Configurable c, String pfx, String[] names, String[] descriptions, boolean[] translatable)booleanisAttributeTranslatable(String attr)Is the specified attribute allowed to be translated?booleanisTranslatable()Return true if this component has any translatable attributes, or if any of its children are translatablevoidsetAllAttributesUntranslatable()Convenience method to force all attributes to be not translatablevoidsetAttributeTranslatable(String attribute, boolean set)Force a specified attribute to be translatable/not translatablevoidsetOwningComponent(Translatable t)Set the owning Translatable of this componentvoidsetPrefix(String p)voidsetUntranslatedValue(String attr, String value)Set an untranslatedValue for the specified attribute.
-
Field Details
-
prefix
-
parent
-
myComponent
-
translatableProperties
-
allProperties
-
children
-
-
Constructor Details
-
ComponentI18nData
Build from an AbstractConfigurable. The parent will be set from AbstractConfigurable.add(). untranslatedValues will be filled in as attributes are translated.- Parameters:
c- AbstractConfigurable componentprefix- I18n Prefix
-
ComponentI18nData
-
ComponentI18nData
Build from an AutoConfigurable- Parameters:
c- AutoConfgurable componentprefix- I18n prefix
-
ComponentI18nData
public ComponentI18nData(Configurable c, String prefix, Translatable parent, String[] names, boolean[] translatable, String[] descriptions)Build from a Configurable. Configurable does not support getAttributeNames() getAttributeTypes() or getAttributeValueString(), so more information must be supplied.- Parameters:
c- Componentprefix- I18n prefixparent- parent translatablenames- Array of attribute namestranslatable- Array of Attribute translatable status
-
ComponentI18nData
-
ComponentI18nData
-
ComponentI18nData
Special build for PrototypeDefinition and PieceSlot
-
-
Method Details
-
init
protected void init(Configurable c, String pfx, String[] names, Class<?>[] types, String[] descriptions) -
init
protected void init(Configurable c, String pfx, String[] names, String[] descriptions, boolean[] translatable) -
getPrefix
Return a unique Key prefix identifying this component -
setPrefix
-
getFullPrefix
Return a unique key prefix including a full path of parent prefixes. All Translatable Pieces share a common prefix.- Returns:
-
getAttributeKeys
Return a list of all of the translatable Keys for attributes of this Translatable item. -
setOwningComponent
Set the owning Translatable of this component -
getOwningComponent
Return the owning Translatable of this component -
isAttributeTranslatable
Is the specified attribute allowed to be translated?- Parameters:
attr- Attribute name- Returns:
- is translatable
-
isTranslatable
public boolean isTranslatable()Return true if this component has any translatable attributes, or if any of its children are translatable- Returns:
- component translatable status
-
setAttributeTranslatable
Force a specified attribute to be translatable/not translatable- Parameters:
attribute- Attribute nameset- translatable status
-
setAllAttributesUntranslatable
public void setAllAttributesUntranslatable()Convenience method to force all attributes to be not translatable -
applyTranslation
Apply a translatation to the specified attribute. Record the untranslated value in the untranslatedValues array and set the new value into the real attribute- Parameters:
attr- Attribute namevalue- Translated value
-
getAttributeDescription
Return description for named Attribute- Parameters:
attr-- Returns:
- description
-
getLocalUntranslatedValue
Return the pre-translation value stored in this Object.- Parameters:
attr- Attribute Name- Returns:
- untranslated value
-
setUntranslatedValue
Set an untranslatedValue for the specified attribute. Used by components that do not subclass AbstractConfigurable- Parameters:
attr- Attribute namevalue- untranslated value
-
getTranslatedValue
-
getChildren
Return all child Translatable components of this component- Returns:
- Child translatables
-
hasUntranslatedAttributes
Return true if this component or any of its children have at least one translatable attribute with a non-null value that does not have a translation in the supplied translation.- Parameters:
t- Translation- Returns:
- true if translation of this component is not complete
-