Package VASSAL.i18n
Class Localization
java.lang.Object
VASSAL.build.AbstractBuildable
VASSAL.build.AbstractConfigurable
VASSAL.i18n.Language
VASSAL.i18n.Localization
- All Implemented Interfaces:
AutoConfigurable
,Buildable
,Configurable
,PropertyNameSource
,ValidityChecker
,Translatable
public class Localization extends Language
Singleton class for managing the translation of a module into other languages
- Author:
- rodneykinney
-
Nested Class Summary
Nested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util
-
Field Summary
Fields Modifier and Type Field Description protected String
countryBundle
protected List<Translation>
countryTranslations
protected String
languageBundle
protected List<Translation>
languageTranslations
protected VassalResourceBundle
masterBundle
protected String
moduleBundle
protected List<Translation>
moduleTranslations
protected Set<TranslatableAttribute>
translatableItems
Record attributes as the module is being built for later translationprotected boolean
translationComplete
protected boolean
translationInProgress
protected List<Translation>
translations
Fields inherited from class VASSAL.build.AbstractConfigurable
changeSupport, config, localizedName, myI18nData, name
Fields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validator
Fields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY
-
Method Summary
Modifier and Type Method Description protected void
addBundle(VassalResourceBundle child)
void
addTranslation(Translation t)
Called whenever a Translation is added to a module or extension.static Localization
getInstance()
Translation
getTranslation(String description)
Return a specified translationString[]
getTranslationList()
Return a list of translations available for editing.boolean
isTranslationComplete()
boolean
isTranslationInProgress()
void
removeTranslation(Translation t)
void
saveTranslatableAttribute(Translatable component, String name, String value)
Record an attribute that may need to be translated.void
translate()
Translate the module.String
translate(String key, String defaultValue)
Translate an individual attribute.Methods inherited from class VASSAL.i18n.Language
addTo, getAllowableConfigureComponents, getAttributeDescriptions, getAttributeNames, getAttributeTypes, getAttributeValueString, getConfigureTypeName, getDescription, getHelpFile, removeFrom, setAttribute
Methods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getAttributeVisibility, getConfigureComponents, getConfigureName, getConfigurer, getI18nData, getI18nPrefix, getLocalizedConfigureName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureName
Methods inherited from class VASSAL.build.AbstractBuildable
build, getAllDescendantComponents, getAllDescendantComponentsOf, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getPropertyNames, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface VASSAL.build.Buildable
build, getBuildElement
-
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
-- 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 over-rides Language over-rides 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
-
translate
Translate an individual attribute.- Parameters:
key
- Attribute KeydefaultValue
- Default value if no translation available- Returns:
- translation
-
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 macthes 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
-