VBA Functions for File Converters

 

File converters for RC-WinTrans are implemented in VBA modules and must provide five functions that are called by RC-WinTrans when using the file converter.  A description of these functions follows.

 

1. "SupportedDataTypes"

 

Public Function SupportedDatatypes() As String

 

DESCRIPTION:

Called by RC-WinTrans to obtain a user-defined string from the file type supported by the converter.  The string should begin with the prefix characters "x-".

EXAMPLE:

"x-adm" or "x-myfiletype"

VBA Code:

  Public Function SupportedDatatypes() As String
SupportedDatatypes = "x-adm"
End Function

 

 

2. "SupportedFileExtensions"

 

Public Function SupportedFileExtensions() As String

 

DESCRIPTION:

Called by RC-WinTrans to obtain the supported file extensions.  A number of file extensions can be returned.  Each file extension must be separated by a comma.
Do not
use a period with the file extension string.

Example: "csv" or "exe,dll,csv"

EXAMPLE:

"x-adm" or "x-myfiletype"

VBA Code:

  Public Function SupportedDatatypes() As String
SupportedDatatypes = "adm"
End Function

 

 

3. "SupportedFileTypeName"

 

Public Function SupportedFileTypeName() As String

 

DESCRIPTION:

Called by RC-WinTrans to obtain the name of the file type.  The string is displayed in the file type combo-box of a "File Open" dialog box.

EXAMPLE:

"MyFileType  Files" or "Windows ADM Files"

VBA Code:

  Public Function SupportedFileTypeName() As String
SupportedFileTypeName = "Windows ADM Files"
End Function

 

^ Top ^

 

4. "FormatFileToXliff"

 

Public Function FormatFileToXliff (ProjName As String, SrcFile As String,  TgtFile As String,

                                                     SrcLangcode As String) As Long

 

DESCRIPTION:

Creates an XML (XLIFF) data file containing the translatable data of the source file to

be translated.  The XLIFF data file is used by RC-WinTrans for further data processing.

PARAMETERS:

"ProjectName"  ->  Not used.

"SrcFile"  ->  The file name (full path) of the source file.

Example: "c:\test\sample.adm"

"TargetXLIFFFile"  ->  The file name (full path) of the XLIFF data file (*.rwtxlf) to be

created and filled with the data from the source file.

Example: "c:\test\sample_adm.rwtxlf"

"SrcLangcode"  ->  The language code of the source language (i.e., the source file's

language code), e.g., "en," en-UK," or "ja."

Return value  ->  "0" when successful.

 

^ Top ^

 

5. "XliffToFormatFile"

 

Public Function XliffToFormatFile (ProjFile As ProjectFile, SrcFile As String,

                            XliffFile As String,TgtFile As String, TgtLangcode As String) As Long

 

DESCRIPTION:

Creates a translated file (target file).

PARAMETERS:

"ProjectFile"  ->  The RC-WinTrans "ProjectFile" COM object representing the

source file in a translation project.

"SrcFile"  ->  The file name (full path) of the source file.

Example: "c:\test\sample.adm"

"XliffFile"  ->  Not used.

"TargetFile"  ->  The file name (full path) of the target file, the translated file to be

created by the "XLIFFToFormatFile" function.

Example: "c:\test\ja\sample.adm"

"TargetLangCode"  ->  The language code of the target language (i.e., the target file's

language code), e.g., "en," en-UK," or "ja."

Return value  ->  "0" when successful.

 

^ Top ^

 

The two primary tasks of a file converter are to read a source file format and to create an XML (XLIFF) data file for RC-WinTrans to use internally.

 

To create and build up an XLIFF data file, RC-WinTrans provides a helper object (RC-WinTrans COM Object Model) called "XliffFile."  Use the "XliffFile" object to add the data that's read from the source file to an XLIFF format file.  This object has only a few methods and is used solely for the purpose of creating an XLIFF file in the simplest manner possible, without any previous knowledge of the XLIFF format.

 

There are three things you need to know before you begin:

1.

A file section must be created first before the data is added.

Method: "AddFileSection"

2.

Data (source text) is added to the XLIFF file as a single translation unit (TU).

Method: "AddTransUnit"

3.

Translation units can be grouped by creating a group and adding TUs to it.

Method: "AddGroup"

 

^ Top ^