Class ComponentI18nData
java.lang.Object
VASSAL.i18n.ComponentI18nData
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
Modifier and TypeClassDescriptionstatic class
An attribute of a Configurable component that can be translated into another language -
Field Summary
Modifier and TypeFieldDescriptionprotected Map
<String, ComponentI18nData.Property> protected List
<Translatable> protected Configurable
protected Translatable
protected String
protected Map
<String, ComponentI18nData.Property> -
Constructor Summary
ConstructorDescriptionComponentI18nData
(AbstractConfigurable c, String prefix) Build from an AbstractConfigurable.ComponentI18nData
(AbstractConfigurable c, String prefix, ArrayList<String> names, ArrayList<Class<?>> types, ArrayList<String> descriptions) Deprecated, for removal: This API element is subject to removal in a future version.ComponentI18nData
(AbstractConfigurable c, String prefix, List<String> names, List<Class<?>> types, List<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 TypeMethodDescriptionvoid
applyTranslation
(String attr, String value) Apply a translation to the specified attribute.Return description for named AttributeReturn a list of all of the translatable Keys for attributes of this Translatable item.Return all child Translatable components of this componentReturn a unique key prefix including a full path of parent prefixes.Return the pre-translation value stored in this Object.Return the owning Translatable of this componentReturn a unique Key prefix identifying this componentgetTranslatedValue
(String attr, Translation translation) boolean
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 void
protected void
init
(Configurable c, String pfx, String[] names, String[] descriptions, boolean[] translatable) boolean
Is the specified attribute allowed to be translated?boolean
Return true if this component has any translatable attributes, or if any of its children are translatablevoid
Convenience method to force all attributes to be not translatablevoid
setAttributeTranslatable
(String attribute, boolean set) Force a specified attribute to be translatable/not translatablevoid
Set the owning Translatable of this componentvoid
void
setUntranslatedValue
(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
@Deprecated(since="2020-10-26", forRemoval=true) public ComponentI18nData(AbstractConfigurable c, String prefix, ArrayList<String> names, ArrayList<Class<?>> types, ArrayList<String> descriptions) Deprecated, for removal: This API element is subject to removal in a future version. -
ComponentI18nData
-
ComponentI18nData
Build from an AutoConfigurable- Parameters:
c
- AutoConfigurable 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:
- Full Prefix
-
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
-
getAttributeDescription
-
getLocalUntranslatedValue
-
setUntranslatedValue
-
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
-