Details
-
New Feature
-
Resolution: Fixed
-
None
-
Medium
-
Added support for terminology images to be imported/exported in zip-archive
-
Empty show more show less
Description
The TBX import should be extended to be able to import images from a zip folder.
According to
https://www.ttt.org/oscarStandards/tbx/tbx_oscar.pdf
there are 2 different ways, the files can be referenced in the TBX file:
11.3 Referencing a file from the back matter
This example shows how to record the location of the graphic in the back matter, rather than embedding the file in
the back matter.
<body>
<termEntry>
...
<descrip type="figure" target="fid-cricketbat">cricket bat</descrip>
...
</termEntry>
</body>
<back>
<refObjectList type="binaryData">
<refObject id="fid-cricketbat">
<itemSet>
<itemGrp>
<item>bat.jpg</item>
<xref target="sports/cricket/bat.jpg"/>
</itemGrp>
</itemSet>
</refObject>
</refObjectList>
</back>{*}
11.4 Referencing a file directly in the entry{*}
This example demonstrates how to use an <xref> element to specify the location of a file on the local file system
directly in the entry, eliminating the need to include information in the back matter.
<termEntry>
...
<xref type="xGraphic" target="sports/cricket/bat.jpg">cricket bat</xref>
...
</termEntry>
We need to support boths.
Also we need to make sure, that reexport of images works in a consistent way.
In the export as TBX the user must be able to choose, if he wants to export the images hex-encoded embedded in the TBX file or as images.
Therefore we implement the following:
- The target attribute of the image reference in the TBX is stored unchanged in translate5 and used like this in an reexport. This is the case independent which of the above cited ways is used in the TBX - or if they had been hex-encoded included in the TBX or uploaded via UI
- For all images no matter where they come from
- a unique file name is generated under which the file is stored on the disk
- the original file name is stored as an attribute in the database
- the original file name is used as file name, when they are exported in a zip or hex-encoded
- For files that have been uploaded via UI, on image export the unique file id is used as value of the target attribute in the TBX
- Information about an image path in the TBX on TBX-import is not stored in translate5. Only the file name
- On rexport independent if the images are stored in the TBX based64-encoded or if they are in the zip file as files all images are shown as located inside a folder "media", which is a local folder. So with a filepath like "media/image.jpg".
- If there are duplicated file names in the TermCollection, that is exported, it is made sure, that the latter files do not overwrite the earlier exported once by making files unique in a numeric way like "image-name1.jpg","image-name2.jpg", etc.
- For sake of simplicity inside translate5 also in the future we will not store/support xref attributes in translate5, that point to images with a local path. Local paths for images do not make sense for a web application. Therefore all images that are imported in translate5 with the syntax as described in point 11.4 above (this syntax: <xref type="xGraphic" target="sports/cricket/bat.jpg">cricket bat</xref>) are converted in an attribute descrip with type figure for storage in translate5. And will also be exported like this in the reexport.
If in an import such attribute contains a filename, but an image with this name can not be found in the imported zip file (or the TBX is uploaded not within a zip) a default image that contains the text "missing image" is used and an error with the name of the missing image is logged to the language resource log.