Translate Function

Each time the Do. . .Loop statement runs in the GetFiles subroutine, the code passes a globalized XML template file and lingo.xml into the private Translate subrouting. The Translate subroutine sets references to XML document objects for the current globalized XML template file and lingo.xml.

Next, Translate sets the async property on each object to FALSE to ensure that the application does not begin processing the objects until the files have loaded completely. The preserveWhiteSpace property maintains the white space and formatting of the original document where possible. When an XML file is used only to store data, you have the option, by setting the property to FALSE, of instructing the processor to regard white space as irrelevant. Next, the files are loaded into memory as XML document objects.

Finally, a call to the GetLingoValues subroutine starts the process of building HTML pages that are returned to the calling function, GetFiles. The call creates a collection of all elements in the template files that have a LID attribute. Finally, the call to GetCharSetValue appends the <HEAD> element of the resulting HTML file with a value for the charset attribute.

Private Sub Translate(ByVal gXMLURL As String, ByVal lXMLURL As String) As String
    On Error GoTo Errhandler

    Set gXML = CreateObject("Microsoft.XMLDOM")
    Set lXML = CreateObject("Microsoft.XMLDOM")

    gXML.async = False
    lXML.async = False

    gXML.preserveWhiteSpace = True
    lXML.preserveWhiteSpace = True

    lXML.Load (lXMLURL)
    If parseError(lXML) Then Exit Function

    gXML.Load (gXMLURL)
    If parseError(gXML) Then Exit Function

    Call GetLingoValues(gXML.selectNodes("//*[@LID]"))
    'set the character set value for particular language
    Call GetCharSetValue