Successfully loaded .qm files, but translator remained empty
-
Hi,
I used the following codes to load .qm files:success = mTranslator.load(mLangFilenames[index], mLangDirName);
load function returns true, however when I tried to installTranslator:
success = QGuiApplication::installTranslator(&mTranslator);
the installation failed. I checked:
mTranslator.isEmpty()
it remained true after
mTranslator.load
, I also stepped into installTranslator in debugging, I found that it seemed that theisEmpty()
returning true that caused the installTranslator to return false.
So I assume that this caused the failure of installTranslator.
Could you please kindly advise me on this issue? Should I provide more input arguments for the load function?Thank you!
-
Hi,
Did you check that your files are not empty ?
-
That seems pretty small for a translation file. Do you have any text translated ?
-
@QTLeearn said in Successfully loaded .qm files, but translator remained empty:
I opened the .qm files
Please describe how do you created those .qm files.
As @SGaist said, the size (23 bytes) seems pretty small.
How many strings have you translated in the .ts files? -
@Pablo-J-Rogina In QML text type I use qsTrID(), with //% //: etc. I used lupdate, lrelease to create .qm files. The program could successfully locate these qm files.
Since I only have about 28 occurrences of text in QML so I don't think the .qm file is too small -
@Pablo-J-Rogina Wait.... The project above is just an example, I also generated .qm files from another project( different amount of texts for sure), the weird thing was the qm file size was also 23 bytes.... I doubt whether the qm files were successfully generated?
-
@QTLeearn said in Successfully loaded .qm files, but translator remained empty:
I doubt whether the qm files were successfully generated?
As @Pablo-J-Rogina already asked - did you actually did some translations in your ts files?
-
@Christian-Ehrlicher We haven't implemented translations yet, as in .ts files:
<translation type="unfinished"></translation>
However there should be real texts displayed instead of the text IDs.I first generated ts files by clicking Tools->External->Linguistic ->update in Qt creator, then by clicking release I created qm files. I also tried to use lupdate command to generate ts files, but errors occurred:
lupdate: could not exec '/usr/lib/qt5/bin/lupdate': No such file or directoryI doubt there are kits related to language of Qt I didn't install? Thank you again for your help!
-
How did you install Qt ?
-
@QTLeearn said in Successfully loaded .qm files, but translator remained empty:
<translation type="unfinished"></translation>
To my understanding, "unfinished" translations don't prevent the process to go on and get the proper .qm files. Those "unfinished" strings will show up with a question mark in Linguist to let the translator now some attention in needed.
instead of the text IDs.
- Could you elaborate what the
text IDs
are? - Could you please should a snippet of the source code with the qsTrID() entries
lupdate: could not exec '/usr/lib/qt5/bin/lupdate': No such file or directory
Please remember that you can run lupdate manually (i.e. from command line). Although you need to locate a proper lupdate executable first.
- Could you elaborate what the
-
@Pablo-J-Rogina I can show you an example of the
qsTrId()
//% "LAST CASE labelText: qsTrId("TEXT_BUTTON_LAST_CASE")
In the .ts file there's:
<message id="TEXT_BUTTON_LAST_CASE"> <location filename="../Resources/HomeScreen.qml" line="124"/> <source>LAST CASE</source> <translation type="unfinished"></translation> </message>
correspondingly
-
@QTLeearn it looks like your .qm file(s) are empty.
Even with no translations provided at all (no "LAST CASE") if the .qm file was properly built and loaded, you should see "TEXT_BUTTON_LAST_CASE" as the "translated" stringSo you need to do the lupdate / translations (Linguist) / lrelease process properly.
-
@Pablo-J-Rogina You are right, I guess some linguistic tools were not installed. When I tried to generate .qm files, Qt creator printed out messages:
Generated 0 translation(s) (0 finished and 0 unfinished)
Ignored 27 untranslated source text(s)
Updating '/TransDemo/languages/lang_de.qm'... -
I don't see anything wrong with those messages - you did not yet translate any message in your ts file so the output is correct.