Class Localization
- All Implemented Interfaces:
AutoConfigurable, Buildable, Configurable, PropertyNameSource, ValidityChecker, Translatable, Auditable, ImageSearchTarget, SearchTarget
Singleton class for managing the translation of a module into other languages
- Author:
- rodneykinney
-
Nested Class Summary
Nested classes/interfaces inherited from interface AutoConfigurable
AutoConfigurable.Util -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected List<Translation> protected Stringprotected List<Translation> protected VassalResourceBundleprotected Stringprotected List<Translation> protected Set<TranslatableAttribute> Record attributes as the module is being built for later translationprotected booleanprotected booleanprotected List<Translation> Fields inherited from class AbstractConfigurable
changeSupport, config, localizedName, myI18nData, nameModifier and TypeFieldDescriptionprotected PropertyChangeSupportprotected Configurerprotected Stringprotected ComponentI18nDataprotected StringFields inherited from class AbstractBuildable
buildComponents, validatorFields inherited from interface Configurable
NAME_PROPERTY -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddBundle(VassalResourceBundle child) voidCalled whenever a Translation is added to a module or extension.static LocalizationgetTranslation(String description) Return a specified translationString[]Return a list of translations available for editing.booleanIs this component a reqired component within its parent?booleanbooleanbooleanisUnique()Does this component need to be unique within it's parent?voidvoidsaveTranslatableAttribute(Translatable component, String name, String value) Record an attribute that may need to be translated.voidTranslate the module.Translate an individual attribute.Methods inherited from class Language
addTo, contains, getAllowableConfigureComponents, getAttributeDescriptions, getAttributeNames, getAttributeTypes, getAttributeValueString, getConfigureTypeName, getDescription, getHelpFile, removeFrom, setAttributeModifier and TypeMethodDescriptionvoidAdds this component to its parent.booleancontains(Translation newTranslation) Class<?>[]String[]Return an array of Strings describing the attributes of this object.String[]Lists all the buildFile (XML) attribute names for this component.Class<?>[]Return the Class for the attributes of this object.Called by theBuildable.getBuildElement(Document)method to write the attributes into an XML elementstatic Stringprotected StringvoidremoveFrom(Buildable parent) Remove this component from its parentvoidsetAttribute(String key, Object value) Sets a buildFile (XML) attribute value for this component.Methods inherited from class AbstractConfigurable
add, addPropertyChangeListener, getAttributeVisibility, getConfigureComponents, getConfigureName, getConfigurer, getExpressionList, getFormattedStringList, getI18nData, getI18nPrefix, getLocalizedConfigureName, getMenuTextList, getNamedKeyStrokeList, getPropertyList, getTypeName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureNameModifier and TypeMethodDescriptionvoidSet the owning translatable of this componentvoidAdd a PropertyChangeListener.getAttributeVisibility(String name) By default, all attributes are visibleConfigureName is used, in particular, by the Editor to track the names of components, and is preferred byUniqueIdManager.protected StringReturns the name of the configurable type for display purposes.voidRemove a Buildable object from this objectvoidprotected voidSets all attributes untranslatable.protected voidsetAttributeTranslatable(String attr, boolean b) Over-ride the default attribute translatability.voidSets the name and fires a PropertyChangeEventMethods inherited from class AbstractBuildable
addImageNamesRecursively, build, buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getNonFolderAncestor, getPropertyNames, setAncestor, validateModifier and TypeMethodDescriptionvoidAdds all images used by this component AND any subcomponents to the collectionvoidBuild this component by getting all XML attributes of the XML element and callingAbstractBuildable.setAttribute(String, Object)with the String value of the attribute<T> List<T> getAllDescendantComponentsOf(Class<T> target) Recursively descend the build tree and return aListof all components that are instances of the given classDeprecated, for removal: This API element is subject to removal in a future version.getBuildElement(Document doc) <T> Enumeration<T> getComponents(Class<T> target) Deprecated, for removal: This API element is subject to removal in a future version.UseAbstractBuildable.getComponentsOf(Class)instead.<T> List<T> getComponentsOf(Class<T> target) Override this method to provide a list of properties to be exposed for use by expressions in the module.voidsetAncestor(Buildable ancestor) voidvalidate(Buildable target, ValidationReport report) Methods inherited from class AbstractImageFinder
addLocalImageNames, getAllImageNames, getLocalImageNamesModifier and TypeMethodDescriptionvoidClasses extending AbstractImageFinder should override this method in order to add the names of any image files they use to the collection.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Auditable
getComponentName, getComponentTypeName
-
Field Details
-
moduleBundle
-
languageBundle
-
countryBundle
-
moduleTranslations
-
languageTranslations
-
countryTranslations
-
translations
-
masterBundle
-
translatableItems
Record attributes as the module is being built for later translation -
translationInProgress
protected boolean translationInProgress -
translationComplete
protected boolean translationComplete
-
-
Method Details
-
getInstance
-
getTranslationList
Return a list of translations available for editing.- Returns:
- Array of available translations
-
getTranslation
Return a specified translation- Parameters:
description- description- Returns:
- Translation object
-
saveTranslatableAttribute
Record an attribute that may need to be translated.- Parameters:
component- component to be translatedname- Attribute name to be translatedvalue- current value of attribute
-
translate
Translate the module. The module and all extensions have now been built, so all Translations are available and all attributes that need to be translated have been recorded. There may be multiple translations that match this Locale, merge them in order - Country overrides Language overrides default. NB - You cannot create a default translation (Module.properties) using the VASSAL editor, but a default file can be placed into a module or extension manually.- Throws:
IOException- oops
-
translate
-
addBundle
-
isTranslationInProgress
public boolean isTranslationInProgress() -
isTranslationComplete
public boolean isTranslationComplete() -
addTranslation
Called whenever a Translation is added to a module or extension. Check if the translation matches our locale. If so, add it to the list of translations to use. There may multiple matching translations at Country, Language and Module level from different extensions.- Parameters:
t- Translation
-
removeTranslation
-
isMandatory
public boolean isMandatory()Description copied from interface:BuildableIs this component a reqired component within its parent?- Specified by:
isMandatoryin interfaceBuildable- Overrides:
isMandatoryin classLanguage- Returns:
- true if component is mandatory
-
isUnique
-
AbstractBuildable.getBuildables()instead.