Previous: Programming Input Modules, Up: Top



7 Programming Output Modules

This chapter is a step-by-step guide that tells how to transform the output module template in a translation module and will also give some hints about programming the actual translation progress.

7.1 Introduction

Output modules are translation modules for the Transtalo Translation System that have to perform the translation to a human language. They go futher where input modules stop: the translation from a human language.

Output modules are simply binaries that accept command line options. They output their results to standard output.

Output modules are specialized in a single language: the target language. The only thing they have to do is translating a SENTENCE object into a real sentence.

7.2 Contacting the Project Maintainer

The first thing you need to do is contacting the project maintainer. You can do that by joining the transtalo IRC channel (#transtalo at irc.oftc.net) or contacting via email (tijmen@users.sourceforge.net).

7.3 Obtaining the Output Module Template from CVS

There is a template available for output modules in CVS. To use it, check it out in a directory:

     $ cd DIRECTORY
     $ cvs -d:ext:username@cvs.sf.net:/cvsroot/transtalo co templates/output-template

The result will be in templates/output-template. (If you aren't a Transtalo developer, use -d:pserver:anonymous@cvs.sf.net:/cvsroot/transtalo.)

The next thing you do is renaming the dir into transtalo_output_xx (with xx changed into the language code) and removing all CVS subdirectories:

     $ mv output-template transtalo_output_xx
     $ cd transtalo_output_xx
     $ rm -rf $(find | grep /CVS)

7.4 Understanding the Template

The src/ subdirectory already has five source files:

main.cc
Here does everything begin. This file is rarely changed. It parses the command line options, checks the dialect (if applicable), changes to the directory of the executable (to safely access data files), parses the XML sentence file, and calls the translate() function.
translate.cc
Here is the function that does the real translation progress. It is nearly empty as you get it.
idiom.cc
Here come the functions that change the idiom things from the source language into idiom of the destination language.
diagnostic.cc
Here are useful functions that output diagnostic messages: errors, warnings, and information messages. It automatically checks the verbosity: if verbosity is verbose, all messages are shown; if verbosity is quiet, no messages are shown; if verbosity is normal, only errors and warnings are shown.
prefix.cc
This is binreloc from autopackage, to find out the directory where the module resists.

You will create more source files that are specialized in one or some language elements.

7.5 Changing the Template

After getting the template, you need to make it ready for your language. Perform the following steps:

7.6 Storing It in CVS

Do the following to store your module in CVS for the first time (i.e. importing it):

     $ cd transtalo_output_xx
     $ make distclean
     $ cvs -d:ext:username@cvs.sf.net:/cvsroot/transtalo import \
         transtalo_output_xx vendor start -m "Initial import of output_xx"

7.7 Getting Information From Files

To be written