Specifications
225
CHAPTER 19
Data Translators
Data translators translate specialized markup—server-side includes, conditional JavaScript
statements, or other code such as PHP3, JSP, CFML, or ASP—into code that can be read and
displayed by Dreamweaver. In Dreamweaver, you can translate attributes within tags as well as
entire tags or blocks of code. All data translators—block/tag or attribute—are HTML files.
Translated tags or blocks of code must be enclosed in locked regions to preserve the original
markup. Translated attributes do not require locks, which makes inspecting the tags that contain
them a simple process.
Data translation—especially for entire tags or blocks of code—might involve complex operations
that either cannot be done with JavaScript or that can be done more efficiently using C. If you are
familiar with C or C++, you should also read “C-Level Extensibility” on page 251.
How data translators work
Dreamweaver handles all translator files the same way, regardless of whether they translate entire
tags or only attributes. At startup, Dreamweaver reads all the files in the Configuration/
Translators folder and calls the
getTranslatorInfo() function to obtain information about the
translator. Dreamweaver ignores any file in which
getTranslatorInfo() does not exist or
contains an error that causes it to be undefined.
Note: To prevent JavaScript errors from interfering with startup, errors in any translator file are reported only after
all translators are loaded. For more information on debugging translators, see “Finding bugs in your translator” on
page 241.
Dreamweaver also calls the translateMarkup() function in all applicable translator files (as
specified in the Translation preferences) whenever the user might have added new or changed
existing content that needs translation. Dreamweaver calls
translateMarkup() when the user
performs one of the following actions:
• Opens a file in Dreamweaver
• Switches back to Design view after making changes in the HTML panel or in Code view
• Changes the properties of an object in the current document
• Inserts an object (using either the Objects panel or the Insert menu)
• Refreshes the current document after making changes to it in another application
• Applies a template to the document
• Pastes or drags content into or within the Document window
• Saves changes to a dependent file