Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: More Macintosh Toolbox /
Chapter 7 - Translation Manager / Writing a Translation Extension


Writing Application Translation Extensions

Most applications can open only a certain number of file types and can therefore declare those openable file types by including an open resource in their resource forks. (See "Declaring the File Types Your Application Can Open" on page 7-13 for details about the open resource.) Some applications, however, need to determine dynamically which files they can open (perhaps because those applications already contain data-conversion capabilities using external filters). For these applications, the open resource alone is inadequate to specify which kinds of files they can open.

A simple way to generate dynamically a list of your application's openable file types is to provide an application translation extension, a translation extension that can create a list of file types and identify files, but which performs no actual translation. Essentially, the application translation extension exists solely to generate the dynamic list of file types your application can open. The source list in the file translation list that your extension returns to Macintosh Easy Open should contain a file type specification for each of those types; for the destination list of types, the file translation list should contain a single file type specification whose format field contains some arbitrary and otherwise unused file type. Suppose this destination file type is 'VOID'.

The open resource in your application should then consist of a static list containing at least the value in the format field of the sole destination file type specification in the file translation list (that is, 'VOID'). The net effect, as far as Macintosh Easy Open is concerned, is that your application can open documents of type 'VOID' and that a translation extension exists that can translate some other file types into type 'VOID'. As a result, the types in that list--which was generated dynamically--are now considered openable by your application.

Of course, in the situation imagined here, you don't want the application translation extension to do any actual data conversion. You indicate this by setting the taDstIsAppTranslation bit in the flags field of the destination file type specification. If this bit is set, Macintosh Easy Open gives the source document directly to your application without translation. No destination document is created.

Note
In the translation choices dialog box (illustrated in Figure 7-3 on page 7-6), a file type whose file type specification has the taDstIsAppTranslation bit set is listed by the application name only; the name of the application translation extension is not listed.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996