beautypg.com

Displaying help, Localizing an extension, Xml string files – Adobe Extending Dreamweaver CS4 User Manual

Page 86

background image

80

EXTENDING DREAMWEAVER CS4

Extending Dreamweaver

Plug-ins (set to

play

at all times) are supported in the

BODY

of extensions. The

document.write()

statement, Java

applets, and Microsoft ActiveX controls are not supported in extensions.

Displaying Help

The

displayHelp()

function, which is part of several extension APIs, causes Dreamweaver to do the following two

things when you include it in your extension:

Add a Help button to the interface.

Call

displayHelp()

when the user clicks the Help button.

You must write the body of the

displayHelp()

function to display Help. How you code the

displayHelp()

function

determines how your extension displays Help. You can call the

dreamweaver.browseDocument()

function to open

a file in a browser or devise a custom way to display Help such as displaying messages in another absolutely positioned
element in alert boxes.

The following example uses the

displayHelp()

function to display Help by calling

dreamweaver.browseDocument()

:

// The following instance of displayHelp() opens a browser to display a file

// that explains how to use the extension.
function displayHelp() {

var myHelpFile = dw.getConfigurationPath() + "ExtensionsHelp/myExtHelp.htm";
dw.browseDocument(myHelpFile);

}

Localizing an extension

Use the following techniques to make it easier to translate your extensions into local languages.

Separate extensions into HTML and JavaScript files. The HTML files can be replicated and localized; the JavaScript
files are not localized.

Do not define display strings in the JavaScript files (check for alerts and UI code). Extract all localizable strings into
separate XML files in the Dreamweaver Configuration/Strings folder.

Do not write JavaScript code in the HTML files except for required event handlers. This eliminates the need to fix
a bug multiple times for multiple translations after the HTML files are replicated and translated into other
languages.

XML string files

Store all strings in XML files in the Dreamweaver Configuration/Strings folder. If you install many related extension
files, this lets you share all strings in a single XML file. If applicable, this also lets you refer to the same string from both
C++ and JavaScript extensions.

You could create a file called myExtensionStrings.xml. The following example shows the format of the file:

This manual is related to the following products: