Exporting and Importing String Entries Using the Automation Interface

InstallShield 2016

InstallShield stores string entries in the ISString table of the main project file (.ism file). InstallShield lets you export the string entries of a language to a text file, which you can send out for translation. After the strings have been translated, you can import the text files into the InstallShield project file.

The String Editor view in InstallShield enables you to manually export and import string entries for a particular language. To automate this process, you can use the InstallShield automation interface.

One of the functions of the automation interface is to provide you with a mechanism for exporting string entries from and importing string entries into a project. What follows is an example of how to achieve this.

Running the Sample VBScript File

To run this sample, you must first copy the sample code shown below into a file called ImportExportStrings.vbs. Then use the command line to export or import the string entries.

Exporting a Language’s String Entries

To export string entries using the code sample, type the following at the command line.

wscript.exe ImportExportStrings.vbs "C:\MyProject.ism" "C:\1033.txt" "1033" "E"

Importing a Language’s String Entries

To import string entries using the code sample, type the following at the command line.

wscript.exe ImportExportStrings.vbs "C:\MyProject.ism" "C:\1033.txt" "1033" "I"

Sample ImportExportStrings.vbs Code

'/////////////////////////////////////////////////////////////////////////////

'BEGIN ImportExportStrings.vbs

'  

'  This utility was designed to assist in the exporting and importing of string entries

'

'

'  File Name: ImportExportStrings.vbs

'

'  Description: Sample VBScript file exports or imports string entries in a text file

'

'  Usage:  To use the objects in this script, make sure you have the

'          following items in place on your system:

'          1. InstallShield must be installed so that

'             the end-user automation is available.

'          2. You must have Windows Scripting Host (Wscript.exe) installed.

'          3. The script expects the following command-line arguments,

'             in this order:

'             a. The fully qualified path to an existing .ism file.

'             b. The fully qualified path to a text file that contains the string entries

'             c. Decimal language identifier

'             d. Import or Export

'

'/////////////////////////////////////////////////////////////////////////////

 

 

If Wscript.Arguments.Count < 1 Then

    Wscript.Echo "InstallShield Subfolder Utility" & _

        vbNewLine & "1st argument is the full path to the .ism file" & _

        vbNewLine & "2nd argument is the full path to the string text file" & _

        vbNewLine & "3rd argument is the decimal language identifier" & _

        vbNewLine & "4th argument is either E or I for Export or Import"

    Wscript.Quit 1

End If

 

' Create the end-user automation object

Dim ISWIProject

Set ISWIProject = CreateObject("IswiAutoAutomation Interface Version.ISWiProject"): CheckError

 

' Open the project specified at the command line

ISWIProject.OpenProject Wscript.Arguments(0): CheckError

 

if(Wscript.Arguments(3)="E")then

    StringsExport ISWIProject,Wscript.Arguments(1),Wscript.Arguments(2)

elseif(Wscript.Arguments(3)="I")then

    StringsImport ISWIProject,Wscript.Arguments(1),Wscript.Arguments(2)

end if

 

' Save and close the project

ISWIProject.SaveProject: CheckError

ISWIProject.CloseProject: CheckError

 

'/////////////////////////////////////////////////////////////////////////////

' Export the language’s string entries

Sub StringsExport(byref p,byval path, byval language)

    p.ExportStrings path, Date , language

    Wscript.Echo "Exported String entries for language " & language & " to " & path

End Sub

 

'/////////////////////////////////////////////////////////////////////////////

' Import the string entries

Sub StringsImport(byref p,byval path, byval language)

    p.ImportStrings path, language

    Wscript.Echo "Imported string entries for language " & language & " from " & path

End Sub

 

'/////////////////////////////////////////////////////////////////////////////

Sub CheckError()

    Dim message, errRec

    If Err = 0 Then Exit Sub

    message = Err.Source & " " & Hex(Err) & ": " & Err.Description

    Wscript.Echo message

    Wscript.Quit 2

End Sub

 

'END ImportExportStrings.vbs

See Also