Display translated error messages for script validation methods
The property UILanguage from the Application object returns the language currently used for the module. You can use the value to display a translated error message, for example, for a single field script validation method as shown in the example below.
If you add the needed languages as project languages to your project in the project settings you can define Script Resources for the needed strings used as error descriptions. The project active language follows the corresponding UI language and automatically returns the corresponding translation.
You can run any Kofax Transformation Toolkit 5.0 application either with an English or German or any other listed language. English and German are installed by default whereas any other language needs to be downloaded from the Kofax Web site and installed separately.
-
Czech (cs)
-
English (en-US and en-GB, which use different date formats)
-
French (fr)
-
German (de)
-
Italian (it)
-
Japanese (ja)
-
Portuguese (pt-BR)
-
Russian (ru)
-
Simplified Chinese (zh-CN)
-
Spanish (es)
-
Swedish (sv-SE)
' This script valdiation method checks wheter the field's content starts with "XYZ"
' if it starts with different characters an error message is displayed
' new way using the project localization mechanism in combination with the script resources
Private Sub ScriptVal_Validate(ByVal pValItem As CASCADELib.ICscXDocValidationItem, ByRef ErrDescription As String, ByRef ValidField As Boolean)
If Left(pValItem.Text, 3) <> "XYZ" Then
ValidField = False
' the following code gets the corresponding translation for the string if available
ErrDescription = Project.Resources.GetString("ScriptValErrDescription")
Else
ValidField = True
End If
End Sub
' old way without using the project localization
Private Sub ScriptVal_Validate(ByVal pValItem As CASCADELib.ICscXDocValidationItem, ByRef ErrDescription As String, ByRef ValidField As Boolean)
' the error message is translated and displayed for the language the application UI currently uses
If Left(pValItem.Text, 3) <> "XYZ" Then
ValidField = False
Select Case Application.UILanguage
Case "en-US" 'American English
ErrDescription = "Field 'InvoiceNo' must start with 'XYZ'."
Case "de" 'German
ErrDescription = "Das Feld 'InvoiceNo' muss immer mit 'XYZ' beginnen."
Case "fr" 'French
ErrDescription = "Le champs 'InvoiceNo' doit toujours commencer par 'XYZ'."
End Select
Else
ValidField = True
End If
End Sub