| Localization of Text Files |
|
|
|
|
Starting with version 2.10 Radialix has a text file parser. Its operation is based upon using templates consisting of regular expressions.
Encoding and template of a text file are detected automatically when the file is added to project. The template is selected depending on the file's extension. Template and encoding can be changed in the file properties dialog on the Source Settings tab. The Compiler field is not used for text files.
In the localized file creation settings, you can select the encoding for the files to be created. The <Default> value stands for the original encoding if it is Unicode. Otherwise, the translation would have the target language's default encoding.
The Ignore encoding errors option disables displaying errors about the inability to translate the encoding for the characters that can normally occur in the strings that are ignored by the template. Three groups of templates are supported: Project – templates stored in the project file. Custom – templates stored in the Radialix settings section of the current user's registry. Default – templates stored in Radialix. These templates are not available for editing. A template can be selected in the properties dialog of the file being localized. When selecting a template, you can as well edit it. Project templates can also be viewed and edited in the project properties dialog, and custom templates – through the Tools>Custom Templates menu. The Templates button on the original resources tab in the file properties dialog opens the dialog for editing templates.
Templates can be moved and copied by dragging with the mouse. To copy a template, hold the Ctrl key down while dragging. Templates can be added and deleted through the context menu commands. A template can be renamed by double-clicking on its name or with the command on the context menu. The checkbox by the template name allows the auto-selection of the template when adding a new file to a project. When the auto-selection is disabled, a template can be selected manually. By default, the auto-selection of templates for INI files is disabled. That is to ensure using the INI parser located below the INI file parser for INI files by default. If necessary, you can set a template for INI files and use the text file parser instead of the INI file parser if the file being localized has features not supported by the INI file parser. That can be done by copying the INI file template from the default templates to the custom templates or project templates. In the Extensions field, enter the semicolon-separated list of file extensions the template is meant for. Example: dat;lbl;dtr. The Format field – format specifiers type in file strings (C, C#, Pascal++, Java, etc.) ESCAPE-characters – type for coding special characters in file strings (-,Multilizer/Sisulizer or C/C++). With the More>Edit button, you can add more character conversions (this button appears only for project templates or custom templates; default templates display the Show button).
In the Character Sequence column, enter the sequence in the original file; in the Mapped to - the conversion result. Each template contains a list of regular expressions, each one of which has a preset selector for resource name, string name, string and comment (columns Resource ID, String ID, String and Comment respectively). A selector can accept values: - - data of the selected type is not contained in the search result. <All> - entire search result is data of the selected type. $1..$15 – subexpression number in the search result that is data of the respective type. Subexpressions in a regular expressions are set in brackets. For example, expression ^([A-Z]*?\d*,\d+?),([^\n\r]*)$ contains subexpressions: [A-Z]*?\d*,\d+? и [^\n\r]*, which match the selectors $1 and $2 respectively. This regular expression matches a string, where subexpression $1 is highlighted with green, and subexpression $2 – with yellow. You can edit the selector by double-clicking on the corresponding cell of the spreadsheet. Regular expressions can be edited in the spreadsheet directly – double-clicking or pressing the F2 key on the cell opens it for editing. A new expression can be added by entering the text in the last row of the spreadsheet, instead of the Enter expression… text or with the context menu commands. To switch turns of the expressions, simply drag them with the mouse. Holding the Ctrl key down while dragging appends a copy of the spreadsheet row. An expression can be deleted with the command on the context menu. You can also disable a regular expression without adding it by toggling the checkbox in the Regular Expression column. The sequence of expressions defines their priority. The expressions positioned higher on the list have higher priority. A template's operating result is displayed in the preview pane. The space characters are displayed with the dot character, and tabs - with the > sign.
The Text tab shows the original file with color selection of the data found. The selection settings can be edited with the Styles… button. In the style customization dialog, you can edit not only background color, but also font, letter case and selection border settings.
Styles are stored in the desktop profile. With the Select File… button on the preview pane, you can upload a different file. You can also upload the file by dragging it from Windows Explorer to the preview pane. The Text tab's context menu contains the commands for finding strings and jumping to a string with required number.
The Strings tab displays data extraction results.
The ID column displays the Resource Type>Resource Name>String Name tree. If the name isn't set, the data obtains an index matching its sequence number. The resource type always has the STRINGS name. The String column displays found strings; the Comment shows comments. Identifiers in TranslationSome cases require resource and string names in localized files to be formed identifying the target language. For example, when localizing strings in the Inno Setup files' [Custom Messages] sections, you are to add a prefix identifying the language to the string name. You can set localized file name formation rules for each template individually on the tabs Target Resource ID and Target String ID.
Identifier formation rules are set as an identifier language and template correspondence table. The Language column displays the translation language the rule corresponds with. The <ANY LANGUAGE> value means that the rule is applicable to any languages. The rules positioned higher to the beginning of the list have higher priority. Therefore, it makes sense to specify only one rule with the <ANY LANGUAGE> tag and position it at the bottom of the list. To switch turns of the rules, use the commands on the context menu or by dragging them with the mouse. Holding the Ctrl key down while dragging appends a copy of the rule. A new rule is also appended when editing data in a spreadsheet row with the Select Language… text. To switch to the editing mode, double-click on the cell to be edited. The checkbox in the Language column enables the rule. The unused rules are ignored when creating the localized files. The ID column of the rules table sets a template for the resource/string name. The template can have the <OriginalID> tag, which would be replaced with the resource/string name from the original file when creating the file. The other tags can be inserted from the context menu in the editing mode.
The <…> button in the identifier field opens the identifier template editing dialog with the preview of the result.
If no rules are set, the original identifiers are saved to the original file. Steps to be followed for extracting data from text files
Steps to be followed for creating localized files
Template ExamplesDAT FileSample DAT file is an INI-style file, except that all of its strings are in the double quotes. The quotes inside a string are set with the \” sequence. Such file is not supported by the INI file parser; therefore, we are going to use the text file parser. Create a template: DAT Files; extension – dat. ESCAPE-characters - C/C++, additional conversion - \” into ”. Regular expression - ^"(.+?)=([^\r\n]*)"$ , string identifier selector - $1, string - $2. As the result, the data will be selected free from the quotes.
INI-Style File with Quoted StringsThese files are in the INI style but have section and string names without the quotes, while the actual strings – in the quotes. The quotes inside a string are set with the two quotes sequence. Also, the file contains comments that begin with the semicolon character in the beginning of the line. Create a new template; extension – ini. ESCAPE-characters – C/C++, additional conversion – ””=>”. Regular expressions:
Result:
|