Localizing a Document Definition
A localized Document Definition is a Document Definition that has been translated into a language other then the language in which it was originally created. When installing ABBYY FlexiCapture, a UI language can be selected. If a Document Definition is available in the selected UI language, this localized version will be used by the product.
When localizing a Document Definition, the following items are translated:
- field captions, buttons, and text in the data form
- field names in the dialog box where data set records are added and edited
- field names in the dialog box where the vendor linked to a training batch can be changed
- field captions displayed to the user when specifying regions that were not detected automatically
- field captions in the database lookup dialog box invoked from the document editor
- column names in the drop-down list displayed in the database lookup dialog box
- rule names displayed to the operator when rule errors occur
- user script messages (for example messages displayed by script rules, export settings and event handlers)
A user editing a Document Definition always works with the original unlocalized values. An operator working in the document editor sees the localized values displayed in the language of the operator's UI.
The localization process
Document Definitions are localized as follows:
- Identifiers of strings that need to be localized are exported to a text file.
- Localized text is provided for each string identifier in the text file.
- Localized text and corresponding identifiers (collectively referred to as the "localization") from the text file are exported to the Document Definition.
Note: The localization is only exported to the Document Definition that contains strings with identifiers used in the localization.
The localization file
The localization file is a TXT file that contains a list of localized strings. Strings in this file are sorted according to the type of interface element in which they appear (field names, Document Definition name, shell messages and script messages) and then alphabetically by name. The Localization Options dialog box contains controls for creating and managing localization files.
Example of a string in a localization file that hasn't been translated yet:
BANK_CODE ,"Код банка"
In this example, BANK_CODE is the identifier of the string. No other field in the Document Definition can have the same identifier. This identifier is generated automatically in one of two ways: based on the name of the field, or using the template FC_<number of the field>.
The identifier is followed by a comma, which is followed by the string which will be displayed to the user, enclosed in quotation marks ("Bank code"). This string is the part that is translated during localization.
When the string is translated and imported back into the Document Definition, a comment delimiter (two slashes) followed by the original string ("Bank Code") is automatically added after the localized string. The original string is the default string which is displayed to users editing the Document Definition.
The string above will look as follows when localized to Russian:
BANK_CODE ,"Код банка" // "Bank Code"
Localization file syntax:
- The identifier of a string and the string itself are separated by a comma (,)
- Comments are preceded by a comment delimiter (//)
- Strings are enclosed in quotation marks ("String")
- Quotation marks inside strings have to be preceded by a backslash (\")
- Backslashes in strings have to be preceded by a backslash (\\)
- Line breaks are indicated with the newline character sequence \n.
Using a localization file to Localize a Document Definition
Creating a localization file
- In the Document Definition Editor, click Document Definition → Localization → Localization Options....
- Select a language for which you want to create a localization file (languages without a localization file have the Nonlocalized status) and click the Export... button.
- In the dialog box that opens, specify the folder in which you want to save the localization file and the name of the file.
Editing a localization file
- Open the localization file in a text editor and translate the strings.
- Save the file. Make sure it is encoded in Unicode.
Importing a localization file to a Document Definition
- In the Document Definition editor, click Document Definition → Localization → Localization Options....
- Select the language for which you want to import a localization file from the list and click the Import... button.
- Specify the path to the localization file in the dialog box that opens.
- After the localization file has been imported, the status of the language will change to Localized.
- Save the Document Definition.
After a localization file has been imported, the data form in the Document Definition editor will still contain default (unlocalized) text. The localized text will only appear in the document editor. Users of the Project Setup Station can only view localized text when testing Document Definitions and only if the localization's language is selected as the interface language of ABBYY FlexiCapture.
If a localized string is longer than the original string, fields on the data form will be moved to accommodate the longer string.
Deleting a localization
- In the Document Definition Editor, open the Document Definition and click Localization → Localization Options....
- Select the language of the localization you want to delete (languages with available localization have the Localized status).
- The status of the language will change to Nonlocalized.
Localizing messages from user scripts
To localize messages from user scripts (such as script rules and event handlers), create an identifier for each message, provide localized text for each message, and reference the identifiers of messages in the script's code.
To export messages from user scripts to a localization file, click Document Definition → Localization → Localization Options.... You can then translate the messages and import the localization file to the Document Definition as described in the "Importing a localization file to a Document Definition" section of this article.
Localized user script messages will be displayed when the corresponding interface language is selected in ABBYY FlexiCapture.
In the Document Definition editor, click Document Definition → Localization → Localizable Script Messages....
A dialog box containing a list of all possible error messages will open. Click the Add..., Edit... and Delete buttons to edit messages. The dialog box that opens when you click Add... or Edit... lets you change the name of the message and its default text.
Calling localized messages from scripts
To call a message from a user script, use the FCTools.LocalizedStrings object. This object uses the IProperties method.
The following code sample returns a localized message that has the identifier MY_ MESSAGE_1:
FCTools.LocalizedStrings.Get ("MY _MESSAGE_1")
12.04.2024 18:16:02