Class Localization

All Implemented Interfaces:
AutoConfigurable, Buildable, Configurable, PropertyNameSource, ValidityChecker, Translatable, Auditable, ImageSearchTarget, SearchTarget

public class Localization extends Language
Singleton class for managing the translation of a module into other languages
Author:
rodneykinney
  • Field Details

    • moduleBundle

      protected String moduleBundle
    • languageBundle

      protected String languageBundle
    • countryBundle

      protected String countryBundle
    • moduleTranslations

      protected List<Translation> moduleTranslations
    • languageTranslations

      protected List<Translation> languageTranslations
    • countryTranslations

      protected List<Translation> countryTranslations
    • translations

      protected List<Translation> translations
    • masterBundle

      protected VassalResourceBundle masterBundle
    • translatableItems

      protected Set<TranslatableAttribute> translatableItems
      Record attributes as the module is being built for later translation
    • translationInProgress

      protected boolean translationInProgress
    • translationComplete

      protected boolean translationComplete
  • Method Details

    • getInstance

      public static Localization getInstance()
    • getTranslationList

      public String[] getTranslationList()
      Return a list of translations available for editing.
      Returns:
      Array of available translations
    • getTranslation

      public Translation getTranslation(String description)
      Return a specified translation
      Parameters:
      description - description
      Returns:
      Translation object
    • saveTranslatableAttribute

      public void saveTranslatableAttribute(Translatable component, String name, String value)
      Record an attribute that may need to be translated.
      Parameters:
      component - component to be translated
      name - Attribute name to be translated
      value - current value of attribute
    • translate

      public void translate() throws IOException
      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

      public String translate(String key, String defaultValue)
      Translate an individual attribute.
      Parameters:
      key - Attribute Key
      defaultValue - Default value if no translation available
      Returns:
      translation
    • addBundle

      protected void addBundle(VassalResourceBundle child)
    • isTranslationInProgress

      public boolean isTranslationInProgress()
    • isTranslationComplete

      public boolean isTranslationComplete()
    • addTranslation

      public void addTranslation(Translation t)
      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

      public void removeTranslation(Translation t)
    • isMandatory

      public boolean isMandatory()
      Description copied from interface: Buildable
      Is this component a reqired component within its parent?
      Specified by:
      isMandatory in interface Buildable
      Overrides:
      isMandatory in class Language
      Returns:
      true if component is mandatory
    • isUnique

      public boolean isUnique()
      Description copied from interface: Buildable
      Does this component need to be unique within it's parent?
      Specified by:
      isUnique in interface Buildable
      Overrides:
      isUnique in class Language
      Returns: