Qt 5.5 tr usage

时间:2023-03-08 17:24:36

in .cpp file, wherever you want, wrap QString with a tr("somesz") rendering it ready to be translated.

in .pro file, specify the readable translation file:

 //*.pro
TRANSLATIONS += *tr_chn.ts
TRANSLATIONS += *tr_la.ts
...

in the project location, call the lupdate.exe in the the desired version folder's bin:

 lupdate *.pro

generated *tr_*.ts file, open them as .txt file, modify the XML formatted file:

 <!--from:-->
<translation type="Unfinished"></translation>
<!--to:-->
<translation>Translated Chars</translation>

in the project location, call the lrelease.exe in the desired version folder's bin as:

 lrelease.exe *tr_*.ts

copy the generated *tr_*.qm file to the release folder with the main application and done.