Merge translation files (.ts) with existing .ts files using QT Utilities (lconvert)

delliottg picture delliottg · Dec 15, 2011 · Viewed 8.4k times · Source

Here's my problem: We've got .ts files for nine different languages for our product. We've added about 100 new strings that need to be translated, but some are for our next release, and some are for the release after that. We've run into problems with translators missing strings or translating strings ahead of time. We want to be able to send them smaller .ts file containing only the strings we want translated now, and then merge that .ts file into the larger .ts file containing the rest of the translation.

Our translators are required to use QT Linguist (previously we let them edit the raw XML with less than stellar results).

One solution would be to use contexts, but our dev team is not very keen on that idea. Another would be to merge the .ts files by hand, but that seems like a recipe for cut & paste errors.

Is there a method with lupdate & the project file to add or merge secondary .ts files? I've read through the forums in QT-land w/o finding the answer, but the switches in lupdate allude to being able to point to other translation files. Specifically the -pro switch which says:

    -pro <filename>
       Name of a .pro file. Useful for files with .pro file syntax but
       different file suffix. Projects are recursed into and merged.

Example1: we have a German .ts file, we want to add 20 strings from a separate German translation file such that the primary translation file contains all the strings including the 20 new ones.

Example2: we have a German .ts file, we want to add 20 strings from a separate German translation file such that the secondary translation file will be merged with the primary during lupdate so that the resultant .qm file contains all the strings including the 20 new ones.

Has anyone done either of these (and either would work) and can you give me some insight?

Answer

delliottg picture delliottg · Dec 15, 2011

The answer doesn't use lupdate, it lies in another utility called lconvert. It's quite easy to create a secondary file that only contains the strings you're interested in (and delete those same strings from the primary file), then run:

lconvert -i primary.ts secondary.ts -o complete.ts

This will take all the strings from the two input files and put them together into the output file. Using this method I was able to create a zero difference file (other than time stamp) of the original file that I'd split the two primary & secondary files from.

This question didn't get a lot of attention, but maybe someone will have this same problem and this will help.