2

I used that example here

There you can see line numbers, for all location tags. I do not want to use linenumbers, since they might change from time to time.

When I open the *.ts file in the Linguist, the *.ui is shown there as well, as you can see here: green area is the UI Widget

The green area is the UI Widget displayed in the Linguist (actually the same view as in the QtCreator Designer).

With that line numbers it is working. Without, not, Why? I do not want to maintenance line numbers in translation files.

(Similar questions: handling ampersands https://stackoverflow.com/questions/33422473/qtranslator-with-linguist-file-not-translatable)

Community
  • 1
  • 1
Ralf Wickum
  • 2,850
  • 9
  • 55
  • 103

1 Answers1

2

These line numbers are needed for QtLinguist to properly highlight code snippets for which translations are made. They mustn't be updated by hand each time. There is special utility for this purpose - lupdate, which updates your *.ts files due to new code changes.

You can get more details about internationalization from this great article

UPD: Feel free to address me more questions in comments, if something is still unclear.

Valery Shevchuk
  • 411
  • 2
  • 9
  • I know that lupdate command. Can I update in the GUI Linguist application as well? – Ralf Wickum Oct 29 '15 at 17:15
  • @RalfWickum, I don't have QtLinguist on my machine now, but as I remember QtLinguist has only functionality for adding and editing existing translations keys, it cannot update *.ts file due to new code changes. The good practise is to add "lupdate" command for all your *.ts files into your build script. So, it will update all *.ts files automatically during the build process. – Valery Shevchuk Oct 29 '15 at 17:27
  • I cant see anything. lupdate tell me this: Found 0 source text(s) (0 new and 0 already existing). Kept 10 obsolete entries – Ralf Wickum Oct 29 '15 at 17:41
  • @RalfWickum, to correctly update *.ts files you need to run lupdate like following - "lupdate your_project.pro -ts file1.ts file2.ts fileN.ts" – Valery Shevchuk Oct 29 '15 at 19:47
  • I do not use *.pro files, only CMakeList.txt – Ralf Wickum Oct 30 '15 at 07:28
  • I used the same without any *.pro file. just the -ts switch in args – Ralf Wickum Oct 30 '15 at 07:42
  • @RalfWickum, that's a wrong way. Without project info (*.pro file provided) lupdate can't update your *.ts files. So, please, try to use "lupdate project.pro -ts file.ts" and you'll get a message like "N sources already existing" and you must get no message about "obsolete" sources. – Valery Shevchuk Oct 30 '15 at 10:33
  • I tried that lupdate CMakeList.txt -ts myfile.ts Same result. As I said, I do not have *.pro files. – Ralf Wickum Oct 30 '15 at 14:07
  • @RalfWickum, can you provide me with your CMakeList.txt file, please? (add it as update to your original post) I'll try to figure out which statements must be added to your CMakeList.txt to automatically generate/update *.ts files and build appropriate *.qm files (your translations won't work without properly compiled *.qm files) – Valery Shevchuk Oct 30 '15 at 14:24