The File format converting tool

1. Introduction

The File format converting tool, in this document called 'converter' was developed to allow converting from the sdf file format to other file formats used in the OpenOffice.org Localization process and vice versa. The converter can do the following tasks:

convert from sdf to gsi and xliff,

merge gsi files back to (the original) sdf file and

create an sdf file from an xliff file constructed by the converter.

2. Usage

The workflow is planned in the way that an sdf file with the source language (default is en-US) is extracted from the sources. This file is converted to gsi or xliff depending on the preferred file format. After translation the resulting file is in case of xliff converted to sdf and in case of gsi merged to sdf using the original sdf file.

The converter is delivered as a java jar archive. It can be used at the command line or in scripts. To start conversion of a sdf file to another format type:

java -jar converter.jar SourceFileNameAndPath TargetFileNameAndPath

This is the shortest way. To use it the file extensions must be either .sdf .gsi or .xliff to ensure the converter uses the right conversion.

For example to convert the file

„C:/Files/fromSource.sdf“ to „X:/NewFiles/notTranslated.xliff“

type:

java -jar converter.jar C:/Files/fromSource.sdf X:/NewFiles/notTranslated.xliff

Of course you must be in the same directory as the converter jar file or have added it to your classpath.

Using the command line above „en-US“ is the default source language and in the case that there are as well strings in a second language in the sdf file, the second language is taken for target language.

To make sure the right language is taken for target use the „-t“ switch and f. e. for using Japanese as target language type:

java -jar converter.jar C:/Files/fromSource.sdf X:/NewFiles/notTranslated.xliff -t ja

If you are using an other language than en-US as source for your translation you must use the „-s“ switch to tell the converter what language is the source language. So if you want to translate from German to Japanese type:

java -jar converter.jar C:/Files/fromSource.sdf X:/NewFiles/notTranslated.xliff -t ja -s de

All errors that occur during this process can be written to a log file using the „-l“ switch. If you do not name the log file a new file is created with name and path of the source file but „.log“ used for the extension. To name the log file just write path and name of the file to create after the -l and a space. Using the same line as above and write the log to X:/LogFiles/SDFtoXLIFF.log just add

...NewFiles/notTranslated.xliff -t ja -s de -l X:/LogFiles/SDFtoXLIFF.log

If a file already exists you will be prompted to allow overwriting. To make it easier to write scripts that make use of the converter you can allow overwriting of existing files using the „-o“ switch.

In the examples used so far the converter gets the type of the source and target file (gsi, sdf, xliff) from the extensions of the files. If you want to use other extensions you must tell the converter what the of the source or target file is using the „-S“ and „-T“ switch (!capital letter) just write the type of the source and/or target file after the switch. Here's an example:

java -jar converter.jar C:/Files/fromSource.txt X:/NewFiles/notTranslated.txt -S sdf -T gsi

If you do not give a target file you must use the “-T” switch. The converter will create the target file with name and path of the given source file but give it the extension that fit the type you desired.

So, by typing:

java -jar converter.jar C:/Files/aFile.sdf -T gsi

a new gsi file is created in C:/Files/aFile.gsi. Of course this will work with xliff and sdf as well.

The exception of the rule is the merging from gsi to sdf. There are two things you must remember when merging gsi files with new translated strings to sdf. First the gsi file lines must be sorted in ascending order. And second the merging needs two sources, first is the gsi files with the translated strings second is the original sdf file. Both must be given. Here is an example:

IMPORTANT: The original SDF File must be kept for converting/ merging back from GSI to SDF.

java -jar converter.jar C:/Files/fromSource.gsi X:/NewFiles/translated.sdf -S gsi X:/notTranslated.sdf -T sdf

Second source Target First source

3. The Logfile

As mentioned above you can make the converter write a logfile by using the “-l” switch. The following information can be found in that file:

All information you see on screen will be written to the logfile. If there occur errors during reading or writing a line the error and the line containing it will be printed; in some cases, if the line with the error can not be printed, the next line will be printed.

The errors can be:

Line errors:	the format of the line has an error (f. e. an sdf line does not contain 15	columns).

Language errors:	f. e. an sdf block must contain the source language or it is skipped by the	converter.

Found not needed language:	found a line with a language id (en-US,de,fr,...) that is neither source	nor target language.

4. Further Information

Here are some useful links to find more information about

The xliff file format:

http://www.oasis-open.org/committees/xliff/documents/xliff-specification.htm

The sdf file format:

http://l10n.openoffice.org/L10N_Framework/Intermediate_file_format.html

The localization process:

http://l10n.openoffice.org/L10N_Framework/iso_code_build2.html

Christian Schmidt

2005-03-21T13:57:30

Christian Schmidt