The user library is an easy to use C interface to the Transtalo Translation System. It actually is a convience library, since it is possible to call the translation modules by hand.
The transtalo user library consists of a number of functions, enumerations and defines. Besides the translation, it also allows looking up information about the available translation modules.
The library's name is libtranstalo
, you can use it by adding
-ltranstalo
to the command line while linking.
#include <transtalo.h> int transtalo_translate(char *source_lang, char *source_lang_dialect, char *dest_lang, char *dest_lang_dialect, char *sentence, char *target, int verbosity);
This function is the library equivalent of the translate command from the transtalo command line interface.
It translates sentence from source_lang with source_lang_dialect as dialect into dest_lang with dest_lang_dialect as dialect and puts it into target.
If source_lang_dialect and/or dest_lang_dialect are NULL, they will be ignored. target must be an initialized string (1000 characters—this will change in the future).
#include <transtalo.h> int transtalo_lang2xml(char *source_lang, char *source_lang_dialect, char *sentence, char *xml_file, int verbosity);
This function is the library equivalent of the lang2xml command from the transtalo command line interface.
It translates sentence from source_lang with source_lang_dialect as dialect into an XML file and puts it into the xml_file file.
If source_lang_dialect is NULL, it will be ignored.
#include <transtalo.h> int transtalo_xml2lang(char *xml_file, char *dest_lang, char *dest_lang_dialect, char *target, int verbosity);
This function is the library equivalent of the xml2lang command from the transtalo command line interface.
It translated the xml_file XML file into dest_lang with dest_lang_dialect as dialect and puts it into target.
If dest_lang_dialect is NULL, it will be ignored. target must be an initialized string (1000 characters—this will change in the future).
#include <transtalo.h> void transtalo_get_modules(char *buffer[], int type);
Get all supported modules of type and put it into buffer. type is one out of TS_INPUT_MODULE and TS_OUTPUT_MODULE.
buffer must be an initialized array of pointers, for example:
char *modules[100];
This will change in the future.
#include <transtalo.h> char *transtalo_get_long_name(const char *lang);
This function returns the full name for the ISO language code in lang.
#include <transtalo.h> TRANSTALO_MODULE_INFO *transtalo_get_info(int module_type, char *language);
This function puts information about the specified translation module into a pointer to a TRANSTALO_MODULE_INFO structure.
module_type is one out of TS_INPUT_MODULE and TS_OUTPUT_MODULE, and specifies wether you want respectively an input or an output module.
language is a string containing the language code you want to get the information from.
The function returns a struct TRANSTALO_MODULE_INFO declared in <transtalo.h> as
typedef struct { char *short_language; char *long_language; char *version; int state; char *authors[16]; char *contributors_name[16]; int *contributors_function[16]; } TRANSTALO_MODULE_INFO;
In the struct state defines how well the module can translate, and is a value from 0 up to 5.
contributors_function is an array which defines the functions of the contributors, anolog to the ones in contributors_name, and is: TS_FUNCTION_UNKNOWN if the function was not specified, TS_FUNCTION_BUG_REPORT if it was a bug reporter, TS_FUNCTION_FEATURE_REQUEST if he or she requested a function, TS_FUNCTION_PATCH if it was someone who provided a patch.
#include <transtalo.h> char *transtalo_get_release();
Returns the release information of the current core library, for example: “Transtalo Translation System, release 0.3.0”.
#include <transtalo.h> char *transtalo_get_copyright();
Returns copyright information of the current core library, for example: “Copyright (C) 2004, 2005 the Transtalo team”.
#include <transtalo.h> char *transtalo_get_version();
Returns the version of the current core library, for example: “0.3.0”.
The verbose variable that is uses in some functions can be one out of:
The first 3 functions that deal with a translation return an integer that is defined as one out of the following: