0

In the documentation of the Qt lrelease tool I read, that .ts files can be compiled to .qm binaries using following command:

lrelease.exe main_en.ts languages\main_fr.ts

Is it possible to take .xliff files as well as input instead of the .ts files to compile .xliff files to .qm files? How is it done?

Marcel Müller
  • 368
  • 3
  • 17

2 Answers2

1

From the documentation of lupdate, it is mentioned that you can generate .ts file from XLIFF files. You can then use lrelease to generate the .qm file.

Be aware that only the XLIFF 1.1 format is supported, not the 1.0.

Frodon
  • 3,684
  • 1
  • 16
  • 33
  • Yes I saw it as well but it doesn't give me a `.ts` file when I call it with a `.xlf` file like following `lupdate E:\Users\\Desktop\<.xlf file>` or `lupdate -ts E:\Users\\Desktop\<.xlf file>` What am I doing wrong? – Marcel Müller Feb 18 '20 at 10:03
  • Can you provide a sample of `xlf` file to make some tests ? – Frodon Feb 18 '20 at 10:11
  • Better check the results though, I’ve had translators use xliff, and the conversion from ts to xliff and back had issues, paragraphs got lost, due to nested elements that linguist’s converter didn’t understand. (don’t have the files around anymore to check the version) – Frank Osterfeld Feb 18 '20 at 10:19
  • @Frodon I think I can provide an `.xlf` file later @FrankOsterfeld so the lupdate doesnt convert between these file types properly? – Marcel Müller Feb 18 '20 at 10:30
  • @FrankOsterfeld Can you give me an example how to call lupdate to convert from xliff to .ts?? – Marcel Müller Feb 18 '20 at 10:32
  • @MarcelMüller I did that from within the Qt Linguist UI – Frank Osterfeld Feb 18 '20 at 15:50
  • @FrankOsterfeld Thank you for your advises I could resolve the problem :) – Marcel Müller Feb 19 '20 at 12:05
1

To convert a xliff file to ts, you can use the lconvert utility with a command line like this:

lconvert -o converted.ts -i original.xlf 

Here is the output of lconvert -help:

Usage: lconvert [options] [...]

lconvert is part of Qt's Linguist tool chain. It can be used as a stand-alone tool to convert and filter translation data files. The following file formats are supported:

qm    - Compiled Qt translations
pot   - GNU Gettext localization template files
ts11  - Qt translation sources (format 1.1)
ts20  - Qt translation sources (format 2.0)
qph   - Qt Linguist 'Phrase Book'
ts    - Qt translation sources (latest format)
po    - GNU Gettext localization files
xlf   - XLIFF localization files

If multiple input files are specified, they are merged with translations from later files taking precedence.

Options: -h --help Display this information and exit.

-i <infile>
--input-file <infile>
       Specify input file. Use if <infile> might start with a dash.
       This option can be used several times to merge inputs.
       May be '-' (standard input) for use in a pipe.

-o <outfile>
--output-file <outfile>

More info here about this Qt tool

Former contributor
  • 2,466
  • 2
  • 10
  • 15