Scripting: Reference

 

The primary scripting functionality is hidden in a VBScript class called "RWTComWrapper."  Before the class can be used you will need to create an instance, as in the following example:

               set RWT = new RWTComWrapper
          If Not RWT.HasLanguage("myProject.rwtproject", "fr") Then
            RWT.AddLanguage "myProject.rwtproject", "fr"
          End If

Quick jump to specific discussions found in this topic:

·

Basic functions of "RWTComWrapper"

·

Extra functions of "RWTComWrapper"

·

"RWTComWrapper" properties

 

 

Basic Functions of "RWTComWrapper"

This section covers the basic functions that are also available in the batch processing model.

Function AddLanguage (RWTProjectFileName, LangCode)

DESCRIPTION:

Adds a new language to the translation project.

PARAMETERS:

RWTProjectFileName ' As String (The full path to the translation project file.)
LangCode ' As String
(The language code to add.)

RETURN VALUE:

Boolean ("True" when successful.)


Function AddSourceFile (RWTProjectFileName, SourceFileName)

DESCRIPTION:

Adds a new source file to the translation project.

PARAMETERS:

RWTProjectFileName ' As String (The full path to the translation project file.)
SourceFileName ' As String
(The full path to the source file.)

RETURN VALUE:

Boolean ("True" when successful.)


Function AddTextToLogFile (Text)

DESCRIPTION:

Writes text as a single line to the log file.  See also the "Logfile" property.

PARAMETERS:

RWTProjectFileName ' As String (The full path to the translation project file.)
SourceFileName ' As String
(The full path to the source file.)

RETURN VALUE:

Boolean ("True" when successful.)


           Function CreateProject (RWTProjectFileName, ProjectName, _
                                   SourceLangCode)

DESCRIPTION:

Creates a new translation project file.

PARAMETERS:

RWTProjectFileName ' As String (The full path to the translation project file.)
ProjectName ' As String
(The string with the name of the project; this name will appear in RC-WinTrans.)
SourceLangCode ' As String
(The language code of the source language.)

RETURN VALUE:

Boolean ("True" when successful.)


Function HasLanguage (RWTProjectFileName, LangCode)

DESCRIPTION:

Verifies the existence of a specified language in the translation project.

PARAMETERS:

RWTProjectFileName ' As String (The full path to the translation project file.)
LangCode ' As String
(The language code of the language to verify.)

RETURN VALUE:

Boolean


        Function ImportFromResourceFile (RWTProjectFileName, LangCode, _
                                         ToProjFile, FromProjFile)

DESCRIPTION:

For a given translation project and a single project file contained within it ("ToProjFile"), takes a translated version of the project file ("FromProjFile") and imports the translations from it for the given language ("LangCode").

PARAMETERS:

RWTProjectFileName ' As String (The full path to the translation project file.)
LangCode ' As String
(The language code of the data within "FromProjFile.")
ToProjFile ' As String
(The full path to the source file as contained in the translation project.)
FromProjFile ' As String
(The full path to the translated resource file.)

RETURN VALUE:

Boolean ("True" when successful.)


Function IsProjectUpToDate (RWTProjectFileName, TargetLangCode)

DESCRIPTION:

Verifies whether any source files have changed by comparing them to the translation project.  This check is only performed for the project file with the given target language.

PARAMETERS:

RWTProjectFileName ' As String (The full path to the translation project file.)
TargetLangCode ' As String
(The target language code to check.)

RETURN VALUE:

Boolean


Function IsTranslated (RWTProjectFileName, TargetLangCode, SourceFileName)

DESCRIPTION:

Verifies whether a given source file contained in a translation project is translated for the specified language.  A file is considered to be translated when a translation (target text) exists for all text items (caption, string, x-text, comboboxitem, comboboxx-item, x-textprop, listitem).

PARAMETERS:

RWTProjectFileName ' As String (The full path to the translation project file.)
TargetLangCode ' As String
(The target language code to check.)
SourceFileName ' As String
(The full path to the source file to check.)

RETURN VALUE:

Boolean


            Function IsUpToDate (RWTProjectFileName, SourceFileName, _
                                 TargetLangCode)

DESCRIPTION:

Verifies whether a given source file has changed by comparing it to the translation project.  This check is only performed for the project file with the given target language.

PARAMETERS:

RWTProjectFileName ' As String (The full path to the translation project file.)
SourceFileName ' As String
(The full path to the source file to check.)
TargetLangCode ' As String
(The target language code to check.)

RETURN VALUE:

Boolean

SAMPLE FILE:

"UpdateAndWrite.wsf"


Function Update (RWTProjectFileName, SourceFileName, TargetLangCode)

DESCRIPTION:

Updates the source file for a given target language.

PARAMETERS:

RWTProjectFileName ' As String (The full path to the translation project file.)
SourceFileName ' As String
(The full path to the source file to update.)
TargetLangCode ' As String
(The target language code for which the update is to be performed.)

RETURN VALUE:

Boolean ("True" when successful.)

SAMPLE FILE:

"UpdateAndWrite.wsf"


Function UpdateAll (RWTProjectFileName, TargetLangCode)

DESCRIPTION:

Updates all the source files in a translation project for a given target language.

PARAMETERS:

RWTProjectFileName ' As String (The full path to the translation project file.)
TargetLangCode ' As String
(The target language code for which the update is to be performed.)

RETURN VALUE:

Boolean ("True" when successful.)


         Function WriteTargetFile (RWTProjectFileName, SourceFileName, _
                                   TargetLangCode, TargetFileName, _
                                   Encoding)

DESCRIPTION:

Writes a target file in a specified language with the optional use of a given encoding (e.g., "default," "UTF-8," or "UTF-16" for Java properties files). Note that if the "TargetFileName" parameter is passed as an empty string (""), the target file rule designated for the project file will be used.

PARAMETERS:

RWTProjectFileName ' As String (The full path to the translation project file.)
SourceFileName ' As String
(The full path to the source file within the translation project.)
TargetLangCode ' As String
(The target language code to use.)
TargetFileName ' As String
(The full path to the target file name to use; may be passed as an empty string ("").
Encoding ' As String
(The string with the encoding to use, e.g., "default," "UTF-8," "UTF-16"; if not needed, pass an empty string ("").

RETURN VALUE:

Boolean ("True" when successful.)

SAMPLE FILE:

"UpdateAndWrite.wsf"


       Function WriteAllTargetFiles (RWTProjectFileName, TargetLangCode, _
                                  Encoding)

DESCRIPTION:

Writes all the target files of a translation project using a given encoding (e.g., "default," "UTF-8," or "UTF-16" for Java properties files).  If the "Encoding" parameter is not used it can be passed as an empty string.  If this parameter cannot be applied to a given file type, it will be ignored.  The target files will be written according to the target path rules specified for the translation project.

PARAMETERS:

RWTProjectFileName ' As String (The full path to the translation project file.)
TargetLangCode ' As String
(The language code for the target file to use.)
Encoding ' As String
(The string with the encoding to use, e.g., "default," "UTF-8," "UTF-16"; if not needed, pass an empty string ("").

RETURN VALUE:

Boolean ("True" when successful.)

 

 

Extra Functions of "RWTComWrapper"

Please note that all subsequent methods need to have the target language code as well.  This is because all information is retrieved from "ProjectFile" objects. A "ProjectFile" object couples the source and target languages.

       Function SourceFilesHaveChanged (ProjectFileName, TargetLangCode, _
                                        ReportFileName)

DESCRIPTION:

Determines whether any source files contained in a translation project have changed.  For details please refer to the "Source File Changes and Data Update" topic.

A report file name to which the output of this method is to be appended may be specified.  If an empty string ("") is passed as "ReportFileName," the output will be sent to the console.

PARAMETERS:

ProjectFileName ' As String (The full path to the translation project file.)
TargetLangCode ' As String
(The target language code to check.)
ReportFileName ' As String
(The full path to the report file to use; if the string is empty ("") the output will be sent to the console.

RETURN VALUE:

Long (A non-negative value indicates the number of changed source files; a negative value indicates that an error has occurred.

SAMPLE FILE:

"MyJob.wsf" / "MyScript.vbs"


         Function TargetFilesAreMissing (ProjectFileName, TargetLangCode, _
                                         ReportFileName)

DESCRIPTION:

Determines whether any target files are missing from a translation project.

A report file name to which the output of this method is to be appended may be specified.  If an empty string ("") is passed as "ReportFileName," the output will be sent to the console.

PARAMETERS:

ProjectFileName ' As String (The full path to the translation project file.)
TargetLangCode ' As String
(The target language code to check.)
ReportFileName ' As String
(The full path to the report file to use; if the string is empty ("") the output will be sent to the console.

RETURN VALUE:

Long (A non-negative value indicates the number of missing target files; a negative value indicates that an error has occurred.

SAMPLE FILE:

"MyJob.wsf" / "MyScript.vbs"


        Function TargetFilesNotUpToDate (ProjectFileName, TargetLangCode, _
                                         ReportFileName)

DESCRIPTION:

Determines whether any target files in a translation project are not up-to-date, i.e., need to be written (see "WriteTargetFile," above).

A report file name to which the output of this method is to be appended may be specified.  If an empty string ("") is passed as "ReportFileName," the output will be sent to the console.

PARAMETERS:

ProjectFileName ' As String (The full path to the translation project file.)
TargetLangCode ' As String
(The target language code to check.)
ReportFileName ' As String
(The full path to the report file to use; if the string is empty ("") the output will be sent to the console.

RETURN VALUE:

Long (A non-negative value indicates the number of target files which are not up-to-date; a negative value indicates that an error has occurred.

SAMPLE FILE:

"MyJob.wsf" / "MyScript.vbs"


      Function TargetFilesNotTranslated (ProjectFileName, TargetLangCode, _
                                         Reportfilename)

DESCRIPTION:

Determines whether any files in a translation project are not fully translated.

A report file name to which the output of this method is to be appended may be specified.  If an empty string ("") is passed as "ReportFileName," the output will be sent to the console.

PARAMETERS:

ProjectFileName ' As String (The full path to the translation project file.)
TargetLangCode ' As String
(The target language code to check.)
ReportFileName ' As String
(The full path to the report file to use; if the string is empty ("") the output will be sent to the console.

RETURN VALUE:

Long (A non-negative value indicates the number of target files which are fully translated; a negative value indicates that an error has occurred.

SAMPLE FILE:

"MyJob.wsf" / "MyScript.vbs"

 

 

"RWTComWrapper" Properties

KeepAlive = NewVal

DESCRIPTION:

Boolean, write-only.

Specifies that the RC-WinTrans server will continue running after your script and "RWTComWrapper" have been terminated.  Without this switch, an instance of RC-WinTrans will shut down after the command has been processed.  Use this property to save time between multiple script calls.


LogFile = NewVal

DESCRIPTION:

String, write-only.

Specifies a "log" file name for program output.  If unset, output will only be generated to the console.


NewVal = IsAlive

DESCRIPTION:

Boolean, read-only.

Verifies that the "RWTComWrapper" object was started successfully.


KillMe = NewVal

DESCRIPTION:

Boolean, write-only.

Forces the termination of the RC-WinTrans application in case of a COM problem. The "kill" is executed in the destructor of the "RWTComWrapper" object.

WARNING: This switch should only be used if there has already been an instance in which RC-WinTrans has crashed.  This switch will try to KILL the RC-WinTrans process. Do not use this switch except in case of a serious problem.


Macro = NewVal

DESCRIPTION:

String, write-only.

Specifies a VBA macro other than "SystemMacros" in case you have your own command dispatcher function.


Module = NewVal

DESCRIPTION:

String, write-only.

Specifies a VBA macro module other than "CommandLine" in case you want to call your own VBA functions.

 

 

^ TOP ^