Document Source Translation; Defining A Translator - Adobe GoLive CS2 Programmer's Manual

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide

Document Source Translation

A
translator Object
generate the DOM. You can use a translator to:
Transform unknown markup elements to a format GoLive can parse, such as XML or HTML.
Mimic the behavior of server-side includes or other dynamic content. A custom element that
incorporates server-based content can substitute placeholder content in Layout view if a live server or
database connection is not available when GoLive parses the document.
The user interacts with translated elements in Layout view by means of custom Inspector windows you
provide. You can translate markup elements temporarily or permanently.

Defining a translator

You use the <jsxtranslator> tag to define your extension's translator object. This element contains
multiple <param> subelements. Each <param> subelement specifies a file type or a source code
expression to translate.
When name="extension" , the element specifies the filename extension for a type of file to
translate. This element's value property specifies a single filename extension. For example:
<param name="extension" value="html">
To operate on multiple file types, a single <jsxtranslator > element can contain multiple <param
name="extension"> subelements. If there is no extension <param> element, GoLive attempts to
translate all file types.
When name="expression" , the element defines a regular expression to replace. This element's
value property specifies a single regular expression. For example,
<param name="expression" value="<include\s*[^>]*>">
To translate multiple text runs, a single <jsxtranslator> element can contain multiple <param
name="expression"> subelements. If there is no expression <param> element, GoLive attempts to
translate all content.
The <param> attribute can speed up the process of calling and evaluating JavaScript by discarding files
that do not match the expression or extension, preventing the execution of JavaScript that would have no
effect.
You can translate markup elements temporarily or permanently using the direction attribute of the
<jsxtranslator> element. A temporary translation is in effect only in layout mode and it does not alter
the code permanently. This allows you to simulate server-side specific translations in the layout process
while preserving the original code.
Translated content in a file is locked in Layout mode—that is, you cannot select the translated text to
change it. The locked text can be visually highlighted with a color, which you can set in the highlight
palette ( Window > Highlight > Colors > Translations ). Set the optional blend attribute of the
<jsxtranslator> element to "no" to suppress color highlighting of the translated text for this module
in the Layout view.
The following example <jsxtranslator> element processes <include> statements in .html and
.htm files:
<jsxtranslator classid="includeClass" direction="twoway" haslinks="yes">
<param name="extension" value="html">
<param name="extension" value="htm">
Adobe GoLive CS2 SDK
modifies a markup document's source code before GoLive parses that source to
Localization and Translation
153

Advertisement

Table of Contents
loading

Table of Contents