创建 Qt 翻译文件
设计应用程序,使其能够适应各种语言和地区,而无需进行工程修改。将 UI 文本标记为可翻译,以创建包含这些文本的 Qt 翻译源 (TS) 文件,并启动Qt Linguist 来翻译字符串。
向项目中添加新的翻译文件:
- 转到Project >Add New Item >Installed >Visual C++ >Qt >Qt Translation File 。
- 在Select a Language 中,从支持的语言列表中选择一种语言。使用Search 筛选特定语言。

- 在Save as 中,输入翻译文件的文件名。
- 转到Finish 以创建文件,并在 Visual Studio 的Solution Explorer 中将其列在Translation Files 中。
- 右键单击翻译文件打开上下文菜单,然后转到
lupdate。它会在源文件、头文件和 UI 文件中找到可翻译的字符串,并生成或更新 TS 文件。
翻译用户界面文本后,转到上下文菜单中的lrelease ,从 TS 文件创建 QM 文件。QM 文件格式是一种紧凑的二进制格式,本地化应用程序使用它来查找翻译。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.