How to make QtLinguist shipped with Qt 5.9.1 work?

隐身守侯 提交于 2019-12-05 01:32:08

The solution

Here is the solution I've found (rather hack-ish, but not too much), based on the info and advices kindly provided by n.m. in the comments under the question:

  1. Create a translate.bat with the following single-line content:

    "%programfiles(x86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" & lupdate.exe %1

and put it under %{CurrentProject:QT_INSTALL_BINS} (in my case C:\Qt\Qt5.9.1\5.9.1\msvc2017_64\bin). Make sure that the translate.bat contains the correct path to vcvars64.bat on your machine. You may as well put another version of vcvars if you need.

  1. In Qt Creator select Tools/Options/Environment/External Tools and then Add Tool under Linguist category. Name it something like Create/Update TS files. Setup the fields for this entry as follows:

    • Executable: %{CurrentProject:QT_INSTALL_BINS}\translate.bat,

    • Arguments: %{CurrentProject:FilePath},

    • Working directory: %{CurrentProject:QT_INSTALL_BINS},

as shown here: External Tools, then apply the changes and close the Options window.

  1. Go to Tools/External/Linguist, select Create/Update TS files and now it should do the job as usual.

The background

Here is once again the link, provided by n.m. in the comments, which served as a base for this solution. Here is also n.m.'s explaination:

Running lupdate from the console most definitely requires that you run vcbars*.bat as described in the link I gave you. That's because lupdate wants to run the compiler and it has no idea where to find it. vcbars*.bat tweaks your PATH and other environment variables. In theory the GUI should set up the environment for you, but in practice it probably doesn't.

ndtc

If you are using Qt5.9.1 of mingw version, you may need to config the system path for mingw compiling tools.

In my case the culprit was the fact that Qt Creator had somehow picked different target ABIs for C and C++:

After fixing this, I managed to get lupdate running with no issues.

You have to run lupdate.exe from VS2015 x86 Native Tools Command Prompt console.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!