Skip to main content

Enabling XML documents for globalization

A simple approach to organizing your translatable XML resources

Return to article


Listing 6: Declaring a supported language


  /**
   * Process an event for an XML tag.
   * 
   * Provide a generic method to execute a specific method based on
   * a mapping of XML tag to method name.
   */
  private void processEvent(Map methodMap, String key, String data)
  {
    String methodName;

    methodName = (String)methodMap.get(key);
    invokeLocalMethod(methodName, data);
  }
  
  /**
   * Answer a map of elements to method names for automatic processing.
   */
  public Map getElementStartMethodMap()
  {
    HashMap myMap = new HashMap();
    myMap.put("translationLanguage","processTranslationLanguage");
    return myMap;
  }
  
  /**
   * Add the specified language to a vector of all languages.
   */
  public void processTranslationLanguage(String aLanguage)
  {
    if (translationLanguages == null)
    {
      translationLanguages = new Vector();
    }
    translationLanguages.add(aLanguage);
  }

Return to article