0

I have added some manual entries in my .ts files that are removed every time I run the lupdate.exe command.

lupdate.exe .. -no-obsolete -locations absolute -ts locale_en.ts locale_fr.ts

I would like lupdate.exe to add the missing entries, to clean the obsolete ones, but preserving the manual entries (that are corresponding to strings to be translated but which translation occurs through a function and not a direct call to either qsTr or qTranslate).

Is this possible ?


My context:

I'm in a pure qml solution without any C backend, without any build or make mechanism. lupdate.exe and lrelease.exe are called manually.

lvr123
  • 524
  • 6
  • 24

1 Answers1

1

You could create an extra translation source (TS) file for the manual entries called additional_locale_fr.ts and merge it with the one generated by lupdate, e.g. locale_fr.ts by using lconvert.

lconvert -i additional_locale_fr.ts locale_fr.ts -o all_locale_fr.ts

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

Also interesting in this context SO.


You could also use QT_TR_NOOP() around your strings in the function. Have a look here and here.

QT_TR_NOOP is used in conjunction with the dynamic translation functions qsTr() and qsTranslate(). It identifies a string as requiring translation (so it can be identified by lupdate), but leaves the actual translation to the dynamic functions.

iam_peter
  • 3,205
  • 1
  • 19
  • 31