File Converter for ADM Files

 

Introduction

This topic describes the procedure for creating a file converter to read and write ADM (administrative template) files so that they can be localized with RC-WinTrans.

 

An ADM file is a textual file. It contains a [strings] section followed by a list of items, each with a key value and text.  The format of the [strings] section and the text entries that follow it is very similar to the format of Windows INI files.  An INI file is different in its use of quotation marks to enclose the text, and it allows text to occupy multiple lines.

 

See the MSDN website (http://msdn2.microsoft.com) for more information on the administrative template file format.

 

In order to localize ADM files (as well as all other file types) with RC-WinTrans they must be converted to the XML format file (XLIFF file) with which RC-WinTrans 9 works internally.  The converter reads the data from a given ADM file, puts it into an XLIFF file for translation in RC-WinTrans, then writes the translated data back into the ADM format to create the translated target file.  The file converter used to read and to write an ADM file is implemented as a VBA (Visual Basic for Applications) project coded in VBA.

 

 

VBA Macro File Converter Basics

A file converter has the task of reading a source file format and creating an XML (XLIFF) file containing its same data.  The XML (XLIFF) file that is created is used by RC-WinTrans for internal processing.  The file converter must also write the translated target file by reading the data from the RC-WinTrans COM object "ProjectFile."  File converters are implemented as VBA modules and must provide five functions that are called by RC-WinTrans to use the converter.  These five functions are:

 

Public Function SupportedDatatypes() As String

 

Public Function SupportedFileExtensions() As String

 

Public Function SupportedFileTypeName() As String

 

Public Function FormatFileToXliff (ProjName As String, SrcFile As String,
TgtFile As String, SrcLangcode As String)  As Long

 

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

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

 

NOTE: A file converter must be supplied to RC-WinTrans as an implementation in a VBA module. However, this does not mean that VBA must also be used to code the essential implementation of a file converter.  The VBA module must provide (at least) the five required functions called by RC-WinTrans. The actual converter could be realized with C++, or as a .NET component, for example, which is used (like the COM object(s)) in the VBA macros.

 

See also:  "Help for Creating XLIFF Data Files."

 

^ Top ^

 

Example

The following example demonstrates how a file converter for ADM files is implemented in a VBA macros file.

 

Sample name:  "ADMFile"

Location of sample file:  ...\Samples\Developing\FileConverter\ADMFile

 

SAMPLE FILE

DESCRIPTION

1. "FileConverter_ADM.macro"

A VBA macros file containing the implementation for the ADM file converter.  "FileConverter_ADM.macro" is a binary file that can be used to add the converter to RC-WinTrans' integrated VBA environment.

2. "ConvADM.bas"

The VBA module with the information for reading, creating, and writing the file.  "ConvADM.bas" is a textual file extracted from the binary macros file.

3. "ADMParser.cls"

The VBA class module containing the ADM files parser class.  The parser uses regular expressions to analyze the ADM file's syntax (line by line).  "ADMParser.cls" is a textual file extracted from the binary macros file.

4. "Strings.adm"

A sample ADM file from Microsoft.

 

^ Top ^

 

Enabling the File Converter

Option 1 – Add the file converter to RC-WinTrans:

Use the File Converters property page in the Options dialog box to add your file converter to the RC-WinTrans system (show image...).  When you use this option the macros file containing the file converter can be placed anywhere on disk.

 

Option 2 – Place the macros file in the "FileConverter" folder:

Copy the macros file to RC-WinTrans' "FileConverter" folder (<InstDir>\RC-WinTrans 9\FileConverter\). Doing this automatically adds the macros files to RC-WinTrans' VBA system when RC-WinTrans is started.  If a macros file contains one or more file converters these will automatically be available for use in RC-WinTrans.

 

You can verify (1) whether a macros file was loaded to the system and (2) if the associated file converter is available for use in RC-WinTrans:

1.

Use the VBA Macros Files property page in the Options dialog box to check if the macros file is loaded.  If the macros file is listed on this page then it has been loaded to the system.  The "Note" column will show the text "auto-loaded" to indicate that the macros file was added to RC-WinTrans' VBA system automatically (show image...).

 

2.

Use the File Converters property page in the Options dialog box to check if the file converter is available for use.  The file converter must be listed and in the file converters list.  The "Note" column will show the text "auto-loaded" to indicate that the converter was added to the RC-WinTrans system automatically (show image...).

 

^ Top ^