Exporting an empty ts file
-
Hello I want to translate my program and use
lupdate.exe -verbose -pro xx.pro -ts xx.ts
to export a ts file.But the ts file is empty. I can see only 1 line in the file that looks like this.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
</TS>I am pretty sure I used tr() in my source files. At least 100+
What's wrong with it? -
Do you use TRANSLATIONS variable in your .pro file?
[Edit ~aha_1980]: Fixed link
-
Do you use TRANSLATIONS variable in your .pro file?
[Edit ~aha_1980]: Fixed link
@sierdzio said in Exporting an empty ts file:
lhttps://doc.qt.io/qt-5/qmake-variable-reference.html#translations
Yes, I followed another guide and added TRANSLATIONS += xx.ts to the pro file. Still got the same ts file.
EDIT: I deleted the original ts file and ran lupdate -verbose xx.pro
again, no ts file came out this time. -
@sierdzio said in Exporting an empty ts file:
lhttps://doc.qt.io/qt-5/qmake-variable-reference.html#translations
Yes, I followed another guide and added TRANSLATIONS += xx.ts to the pro file. Still got the same ts file.
EDIT: I deleted the original ts file and ran lupdate -verbose xx.pro
again, no ts file came out this time.@MasterBlade
for lupdate to work, all files that contain the tr()- macro need to be derived from QObject, or contain the Q_DECLARE_TR_FUNCTIONS(context)- macro.Also iirc, not all lupdate-programs work equally good. What compiler have you set for your program when you want to run it, from out of QtCreator.
-
@MasterBlade
for lupdate to work, all files that contain the tr()- macro need to be derived from QObject, or contain the Q_DECLARE_TR_FUNCTIONS(context)- macro.Also iirc, not all lupdate-programs work equally good. What compiler have you set for your program when you want to run it, from out of QtCreator.
@J.Hilk said in Exporting an empty ts file:
for lupdate to work, all files that contain the tr()- macro need to be derived from QObject, or contain the Q_DECLARE_TR_FUNCTIONS(context)- macro.
Also iirc, not all lupdate-programs work equally good. What compiler have you set for your program when you want to run it, from out of QtCreator.
Sorry I didn't understand. Do you mean the classes I am using must derive from QObject?
Most of tr() are called from QLabels and QPushbuttons, I believe they come from QObject.
I am using MSVC 2017 as compiler. lupdate comes from C:\Qt\5.11.1\msvc2017_64\bin\lupdate.exe. That should match.
EDIT: This time I tried Qt Command Prompt and ran lupdate. There was an error message saying
WARNING: Project ERROR: Cannot run compiler 'cl'. Output: =================== =================== Maybe you forgot to setup the environment?
I'm sure I added TRANSLATIONS += xx.ts to the pro file (though xx.ts does not exist)
-
@J.Hilk said in Exporting an empty ts file:
for lupdate to work, all files that contain the tr()- macro need to be derived from QObject, or contain the Q_DECLARE_TR_FUNCTIONS(context)- macro.
Also iirc, not all lupdate-programs work equally good. What compiler have you set for your program when you want to run it, from out of QtCreator.
Sorry I didn't understand. Do you mean the classes I am using must derive from QObject?
Most of tr() are called from QLabels and QPushbuttons, I believe they come from QObject.
I am using MSVC 2017 as compiler. lupdate comes from C:\Qt\5.11.1\msvc2017_64\bin\lupdate.exe. That should match.
EDIT: This time I tried Qt Command Prompt and ran lupdate. There was an error message saying
WARNING: Project ERROR: Cannot run compiler 'cl'. Output: =================== =================== Maybe you forgot to setup the environment?
I'm sure I added TRANSLATIONS += xx.ts to the pro file (though xx.ts does not exist)
@MasterBlade said in Exporting an empty ts file:
============
Maybe you forgot to setup the environment?
No, thats exactly what I meant i have the same issue with msvc2015. lupdate simply doesn't work. I explicetly switch to mingw, to run lupdate
-
@MasterBlade said in Exporting an empty ts file:
============
Maybe you forgot to setup the environment?
No, thats exactly what I meant i have the same issue with msvc2015. lupdate simply doesn't work. I explicetly switch to mingw, to run lupdate
@J.Hilk said in Exporting an empty ts file:
@MasterBlade said in Exporting an empty ts file:
============
Maybe you forgot to setup the environment?
No, thats exactly what I meant i have the same issue with msvc2015. lupdate simply doesn't work. I explicetly switch to mingw, to run lupdate
I searched the web and found a solution. Add path for cl.exe (C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\Hostx64\x64) to system PATH.
Everything went alright after that.