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

后端 未结 3 537
忘掉有多难
忘掉有多难 2021-02-07 03:07

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

相关标签:
3条回答
  • 2021-02-07 03:12

    Using Multiple Translations

    Multiple translation files can be installed in an application. Translations are searched for in the reverse order in which they were installed, so the most recently installed translation file is searched for translations first and the earliest translation file is searched last. The search stops as soon as a translation containing a matching string is found.

    This mechanism makes it possible for a specific translation to be "selected" or given priority over the others; simply uninstall the translator from the application by passing it to the QApplication::removeTranslator() function and reinstall it with QApplication::installTranslator(). It will then be the first translation to be searched for matching strings.

    proof link : QTranslator Class Reference

    0 讨论(0)
  • 2021-02-07 03:13

    thanks for this tip. It seems to work properly for my case : I tried to extract updated and new strings from my project, which is currently under translation in an older version/release that I do not already have translated strings.

    The problem was to send the new/updated strings only to translators.

    I passed older strings in status resolved, adding new string using Lupdate, make a research using OxygenXML Editor with an XPath "/TS/context/message[not(translation/@type)]" to delete older strings, and clean it from useless blanks and carriage returns.

    I tried a merge using lconvert with your solution, in order to merge translated strings : older and newer. It pass correctly lrelease and are displayed properly.

    0 讨论(0)
  • 2021-02-07 03:14

    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.

    0 讨论(0)
提交回复
热议问题