TS Filter

From Okapi Framework
Revision as of 19:12, 4 June 2016 by Ysavourel (talk | contribs) (1 revision imported)
Jump to navigation Jump to search

Overview

The TS Filter is an Okapi component that implements the IFilter interface for Qt TS (Translation Source) resource files. The filter is implemented in the class net.sf.okapi.filters.ts.TsFilter of the library.

The implementation is based on the TS specification found at http://doc.trolltech.com/4.3/linguist-ts-file-format.html.

Processing Details

Line-Breaks

The type of line-breaks of the output is the same as the one of the original input.

Type

In TS files the <translation> element of a message can have a type element indicating the state of the translation or of the message. This attribute is mapped the following way:

No type attribute The entry is extracted with its target property approved set to "yes".
type is "unfinished" The entry is extracted with its target property approved set to "no".
type is "obsolete" The entry is not extracted. According the Qt manual, the entries with the translation marked as obsolete are unused entries, not just obsolete translation (with new text).

Translator Comment

The TS filter stores <translatorcomment> elements as text unit Property.TRANSNOTE. This property can be used by subsequent steps or editors.

Parameters

Options Tab

Processing mode

Convert <byte value="[value]"/> to raw characters — Select this option to convert all <byte/> elements in the TS document to raw characters. If this option is not set, the elements will not be converted and will be treated as inline codes. Note that those characters are stored special elements in TS because they are invalid in XML, so it may be better to keep them as inline code if you are working with other XML-based formats like XLIFF or TMX.

Inline Codes Tab

Has inline codes as defined below: — Set this option to use the specified regular expressions on the text of the extracted items. Any match will be converted to an inline code. By default the expression is:

((%(([-0+#]?)[-0+#]?)((\d\$)?)(([\d\*]*)(\.[\d\*]*)?)[dioxXucsfeEgGpn])
|((\\r\\n)|\\a|\\b|\\f|\\n|\\r|\\t|\\v)
|(\{\d.*?\}))

Add — Click this button to add a new rule.

Remove — Click this button to remove the current rule.

Move Up — Click this button to move the current rule upward.

Move down — Click this button to move the current rule downward.

[Top-right text box] — Enter the regular expression for the current rule. Use the Modify button to enter the edit mode. The expression must be a valid regular expression. You can check the syntax (and the effect of the rule) as it automatically tests it against the test data in the text box below and shows the result in the bottom-right text box.

Modify — Click this button to edit the expression of the current rule. This button is labeled Accept when you are in edit mode.

Accept — Click this button to save any changes you have made to the expression and leave the edit mode. This button is labeled Modify when you are not in edit mode.

Discard — Click this button to leave the edit mode and revert the current rule to the expression it had before you started the edit mode.

Patterns — Click this button to display some help on regular expression patterns.

Test using all rules — Set this option to test all the rules at the same time. The syntax of the current rule is automatically checked. See the effect it has on the sample text. The result of the test are displayed in the bottom right result box. The parts of the text that are matches of the expressions are displayed in <> brackets. If the Test using all rules option is set, the test takes all rules of the set in account, if it is not set only the current rule is tested.

[Middle-right text box] — Optional test data to test the regular expression for the current rule or all rules depending on the Test using all rules option.

[Bottom-right text box] — Shows the result of the regular expression applied to the test data.

Limitations

None known.