如何使 Qt 5.9.1 附带的 QtLinguist 工作? [英] How to make QtLinguist shipped with Qt 5.9.1 work?

查看:72
本文介绍了如何使 Qt 5.9.1 附带的 QtLinguist 工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:使用 lupdate 生成/更新 Qt 小部件应用的 *.ts 文件.

Goal: Generate/update the *.ts files of a Qt widgets app using lupdate.

设置:

  • Windows 7 Pro 64(也在 Windows 10 Home 上尝试过)
  • 适用于 msvc2017 64 位的 Qt 5.9.1 Prebult 组件,
  • Visual Studio 社区 2017.

问题:我已经从 QtCreator 运行了 lupdate,也从控制台手动运行,但在这两种情况下都无法正常工作.消息是:

The problem: I have run lupdate from the QtCreator, as well as manually from the console, but in neither case it is working. The message is:

启动外部工具C:\Qt\Qt5.9.1\5.9.1\msvc2017_64\bin\lupdate.exe"C:/Documents/Projects/untitled1/untitled1.pro 警告:项目错误:无法运行编译器cl".也许你忘记设置环境了?

Starting external tool "C:\Qt\Qt5.9.1\5.9.1\msvc2017_64\bin\lupdate.exe" C:/Documents/Projects/untitled1/untitled1.pro WARNING: Project ERROR: Cannot run compiler 'cl'. Maybe you forgot to setup the environment?

C:\Qt\Qt5.9.1\5.9.1\msvc2017_64\bin\lupdate.exe"完成

"C:\Qt\Qt5.9.1\5.9.1\msvc2017_64\bin\lupdate.exe" finished

否则项目编译、运行和调试都没有问题,套件:Desktop Qt 5.9.1 MSVC2017 64bit(默认),这就是我认为环境设置正确的原因

Otherwise the project is compiled, run and debugged without problems with the kit: Desktop Qt 5.9.1 MSVC2017 64bit (default), which is the reason I think the environment is properly set up.

我找不到有关此问题的任何信息.任何想法如何使 lupdate 工作?

I can't find any information regarding this issue. Any ideas how to make lupdate work?

我正在添加当前设置(由 Qt 安装程序制作)的屏幕截图,试图阐明为什么我认为环境设置正确:

I am adding screenshots of the current setup (which is made by the Qt installer) in attempt to clarify why I believe the environment is properly set up:

工具包

cmake 配置

推荐答案

解决方案

根据 nm 在问题下的评论中提供的信息和建议,这是我找到的解决方案(相当 hack-ish,但不是太多):

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. 使用以下单行内容创建一个 translate.bat:

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

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

并将其放在 %{CurrentProject:QT_INSTALL_BINS} 下(在我的例子中是 C:\Qt\Qt5.9.1\5.9.1\msvc2017_64\bin).确保 translate.bat 包含您机器上 vcvars64.bat 的正确路径.如果需要,您也可以放置另一个版本的 vcvars.

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. Qt Creator 中选择 Tools/Options/Environment/External Tools,然后在 Linguist 下选择 Add Toolem> 类别.将其命名为创建/更新 TS 文件.设置此条目的字段如下:

  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:

  • 可执行文件:%{CurrentProject:QT_INSTALL_BINS}\translate.bat,

参数:%{CurrentProject:FilePath},

工作目录:%{CurrentProject:QT_INSTALL_BINS},

如下所示:外部工具,然后应用更改并关闭选项窗口.

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

  1. 转到工具/外部/语言学家,选择创建/更新 TS 文件,现在它应该像往常一样完成工作了.
  1. Go to Tools/External/Linguist, select Create/Update TS files and now it should do the job as usual.

背景

这里又是 link,由 nm 在评论中提供,作为此解决方案的基础.这也是 n.m. 的解释:

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:

从控制台运行 lupdate 绝对需要您运行vcbars*.bat 如我给您的链接中所述.那是因为lupdate 想要运行编译器,但它不知道在哪里可以找到它.vcbars*.bat 调整您的 PATH 和其他环境变量.在理论上 GUI 应该为您设置环境,但实际上可能没有.

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.

这篇关于如何使 Qt 5.9.1 附带的 QtLinguist 工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆