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
  • Field Details

  • Constructor Details

    • ComponentI18nData

      public ComponentI18nData(AbstractConfigurable c, String prefix)
      Build from an AbstractConfigurable. The parent will be set from AbstractConfigurable.add(). untranslatedValues will be filled in as attributes are translated.
      Parameters:
      c - AbstractConfigurable component
      prefix - 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

      public ComponentI18nData(AbstractConfigurable c, String prefix, List<String> names, List<Class<?>> types, List<String> descriptions)
    • ComponentI18nData

      public ComponentI18nData(AutoConfigurable c, String prefix)
      Build from an AutoConfigurable
      Parameters:
      c - AutoConfigurable component
      prefix - 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 - Component
      prefix - I18n prefix
      parent - parent translatable
      names - Array of attribute names
      translatable - Array of Attribute translatable status
    • ComponentI18nData

      public ComponentI18nData(Configurable c, String prefix, Translatable parent)
    • ComponentI18nData

      public ComponentI18nData(Configurable c, String prefix)
    • ComponentI18nData

      public ComponentI18nData(Configurable c, GamePiece piece)
      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

      public String getPrefix()
      Return a unique Key prefix identifying this component
    • setPrefix

      public void setPrefix(String p)
    • getFullPrefix

      public String getFullPrefix()
      Return a unique key prefix including a full path of parent prefixes. All Translatable Pieces share a common prefix.
      Returns:
      Full Prefix
    • getAttributeKeys

      public Collection<String> getAttributeKeys()
      Return a list of all of the translatable Keys for attributes of this Translatable item.
    • setOwningComponent

      public void setOwningComponent(Translatable t)
      Set the owning Translatable of this component
    • getOwningComponent

      public Translatable getOwningComponent()
      Return the owning Translatable of this component
    • isAttributeTranslatable

      public boolean isAttributeTranslatable(String attr)
      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

      public void setAttributeTranslatable(String attribute, boolean set)
      Force a specified attribute to be translatable/not translatable
      Parameters:
      attribute - Attribute name
      set - translatable status
    • setAllAttributesUntranslatable

      public void setAllAttributesUntranslatable()
      Convenience method to force all attributes to be not translatable
    • applyTranslation

      public void applyTranslation(String attr, String value)
      Apply a translation to the specified attribute. Record the untranslated value in the untranslatedValues array and set the new value into the real attribute
      Parameters:
      attr - Attribute name
      value - Translated value
    • getAttributeDescription

      public String getAttributeDescription(String attr)
      Return description for named Attribute
      Parameters:
      attr - Attribute
      Returns:
      description
    • getLocalUntranslatedValue

      public String getLocalUntranslatedValue(String attr)
      Return the pre-translation value stored in this Object.
      Parameters:
      attr - Attribute Name
      Returns:
      untranslated value
    • setUntranslatedValue

      public void setUntranslatedValue(String attr, String value)
      Set an untranslatedValue for the specified attribute. Used by components that do not subclass AbstractConfigurable
      Parameters:
      attr - Attribute name
      value - untranslated value
    • getTranslatedValue

      public String getTranslatedValue(String attr, Translation translation)
    • getChildren

      public List<Translatable> getChildren()
      Return all child Translatable components of this component
      Returns:
      Child translatables
    • hasUntranslatedAttributes

      public boolean hasUntranslatedAttributes(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.
      Parameters:
      t - Translation
      Returns:
      true if translation of this component is not complete