-
New Feature
-
Resolution: Done
-
None
-
None
-
Emptyshow more show less
Concept for implementation
This concept makes it possible to translate any file formats as display texts. The only requirement: All texts in a file must have the same length, the same font and the same font size.
Alternatively based on this concept it would be quite easy to develop an import for a custom xml, that contains informations for each xml-tag, with which font and font-size it will be displayed. Then it would even be possible to control different sizes and fonts in the same file (this alternative is not part of this issue).
Mapping of pixel width for each character of a font
For each character in a font a pixel-based width value is mapped. This mapping can be imported into translate5 based on a 5 column Excel file (xlsx; columns: customer number in translate5, font-name, font-size, unicode character, pixel width).
This file is parsed with an import task. It can be part of an import task and is always parsed and updated, if it is part of the import task. If it already parsed for this customer, it does not have to be parsed again as long as nothing is changed.
Other customer-specific parsing possibilites (such as specific XML files for mapping characters) could be implemented easily in addition (not part of this issue). Also a script could be developed, that determines the length of a character for a font automatically based on rendering a small image for each character for each font size and measuring the width of the image (not part of this issue). Since font rendering widths might not be the same on each operating system, there is the risk that the automaticly generated values might have the need to be adjusted afterwards to fit the exact needs of the customer.
How to determine the length and how to interact with the user
If someone edits a segment, that stands for a display text, the translate5 JS front-end calculates the pixel-based length based on the values that have been imported.
If a segment is to long or short enough it is visualized completely analogous to the current character-based length restriction: An icon shows the current number of used pixels. The color of the icon is green if the length is short enough and red if not. If it is red, saving the segment is not possible.
Definition of length restrictions
How many pixels a text can be maximally, which font and which font size is used is defined in the task templates of translate5.
If the length restriction is defined for a trans-unit in an xliff document, this takes precedence over a definition in the task template. An example, how this looks like in the xliff is the following:
<trans-unit id="253" maxwidth="75" size-unit="pixel" ax:state-name="Corrected" ax:state-id="183" ax:state-flags="4194304">
{{ <source><ph id="1" ax:element-id="0"><p_in></ph>Inspektion <ph id="2" ax:element-id="1"></p_in></ph></source>}}
{{ <target><ph id="1" ax:element-id="0"><p_in></ph>Ispezione <ph id="2" ax:element-id="1"></p_in></ph></target>}}
</trans-unit>
Be careful, the size-unit attribute defaults to pixel, so if it is omitted, pixel is defined. See http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#size-unit and http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#maxwidth for more information.
Alternatively the current concept could be extended to support xml files with different length restrictions for each xml tag (not part of this issue).
Handling of whitespace
Whitespace tags will be counted with the pixel length that is defined for them in the mapping table (see above).
- causes
-
TRANSLATE-1875 Testcases for Pixel-based length restrictions
- Backlog