当qml文件添加到qrc文件中,实现internationalization(国际化)
lupdate test.pro只检测 SOURCE 和 HEADER中的文件,当qml文件添加到qrc中时lupdate test.pro时不能被检测到,这时需要手动添加qml文件或者ts文件告诉lupdate时检测,
具体步骤,example:
test.pro文件
TRANSLATIONS += \
fr.ts \
ch.ts \ // 这里是需要生成的翻译的语言生成的ts文件
lupdate_only{
SOURCES += \
test.qml \
common/*.qml \
}
然后lupdate test.pro就OK了
Usage: lupdate [options] [project-file] lupdate [options] [source-file|path]... -ts ts-files Options: -help Display this information and exit. -noobsolete Drop all obsolete strings. -extensions <ext>[,<ext>]... Process files with the given extensions only. The extension list must be separated with commas, not with whitespace. Default: 'ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx'. -pluralonly Only include plural form messages. -silent Don't explain what is being done. -version Display the version of lupdate and exit.
lrelease test.pro生成qm文件
Usage: lrelease [options] project-file lrelease [options] ts-files [-qm qm-file] Options: -help Display this information and exit -compress Compress the .qm files -nounfinished Do not include unfinished translations -removeidentical If the translated text is the same as the source text, do not include the message -silent Don't explain what is being done -version Display the version of lrelease and exit