当前位置:网站首页>QT language file production
QT language file production
2022-08-05 02:46:00 【rainbow_lucky0106】
Purpose
Extract the text in the code to facilitate subsequent changes according to user requirements.
Steps
- Add language file path to .pro file
TRANSLATIONS += .\tcd_language_English.ts \.\tcd_language_Chinese.tsGenerate ts: select Tools > External > Qt Linguist > Update Translation in QTCreate

View ts files with Linguist that comes with QT.In the pop-up language translation interface, add the appropriate translation language.


Publish and generate qm files: in QTCreate, select Tools > External > Qt Linguist > publish translation.
Add the generated qm file to the resource file .qrc.
The code is loaded into the program.
// Multiple qm language files added: use multiple QTranslator objectsQTranslator SysTranslator1;QTranslator SysTranslator2;SysTranslator1.load(QString(":/Resource/qt_zh_CN.qm"));SysTranslator2.load(QString(":/Resource/tcd_language_English.qm"));a.installTranslator(&SysTranslator1);a.installTranslator(&SysTranslator2);How to update
- Find the corresponding entry in QT Linguist to modify.
- Fill in the translation information.

Tricks
The string in tr() is a variable: tr("%1").arg()
tr(QString()) will cause QT Linguist to not recognize
If the source text has variables in the code, it may or may not be written in the translated text.
Source text: tr("The preset time has been recorded %1min").arg(time);
The translation text can be written as: tr("The preset time is up.") or tr("Default %1 minutes.")
边栏推荐
- 01 【前言 基础使用 核心概念】
- C学生管理系统 头添加学生节点
- QT:神奇QVarient
- C language diary 9 3 kinds of statements of if
- View handler stepping record
- Ant Sword Advanced Module Development
- The design idea of DMicro, the Go microservice development framework
- How OpenGL works
- Pisanix v0.2.0 发布|新增动态读写分离支持
- 行业案例|世界 500 强险企如何建设指标驱动的经营分析系统
猜你喜欢
![[ROS] (10) ROS Communication - Service Communication](/img/4d/4657f24bd7809abb4bdc4b418076f7.png)
[ROS] (10) ROS Communication - Service Communication

VSCode Change Default Terminal 如何修改vscode的默认terminal

nodeJs--封装路由

2022-08-04: Input: deduplicated array arr, the numbers in it only contain 0~9.limit, a number.Return: The maximum number that can be spelled out with arr if the requirement is smaller than limit.from

【OpenCV 图像处理2】:OpenCV 基础知识

基于左序遍历的数据存储实践

C语言日记 9 if的3种语句
![[LeetCode Brush Questions] - Sum of Numbers topic (more topics to be added)](/img/ee/6b52072c841af99488dc0c1141c74c.png)
[LeetCode Brush Questions] - Sum of Numbers topic (more topics to be added)

常见的硬件延迟

shell语句修改txt文件或者sh文件
随机推荐
tree table lookup
程序员的七夕浪漫时刻
627. 变更性别
Snapback - same tree
shell statement to modify txt file or sh file
蚁剑高级模块开发
1873. 计算特殊奖金
02 【开发服务器 资源模块】
解决端口占用问题 Port xxxx was already in use
02 [Development Server Resource Module]
数据增强Mixup原理与代码解读
The problem of lack of dynamic library "libtinfo.so.5" in ksql application under UOS system
dmp(dump)转储文件
C语言日记 9 if的3种语句
22-07-31周总结
Cloud Native (32) | Introduction to Platform Storage System in Kubernetes
HDU 1114: Piggy-Bank ← The Complete Knapsack Problem
undo problem
Matlab map with color representation module value size arrow
PostgreSQL数据库 用navicat 打开表结构的时候报错 cannot update secondarysnapshot during a parallel operation 怎么解决?