User Guide
Localizing an extension 27
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 layer 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 will not be 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:
<strings>
<!-- errors for feature X -->
<string id="featureX/subProblemY" value="There was a with X when you did Y.
Try not to do Y!"/>
<string id="featureX/subProblemZ" value="There was another problem with X,
regarding Z. Don't ever do Z!"/>
</strings>