Files
update-client/i18n

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
客户端国际化说明
================

本目录保存 Qt 国际化资源。

文件说明:

1. update-client_zh_CN.ts
   翻译源文件。新增或修改代码里的 tr() 文案后,需要更新这个文件,再补中文翻译。

2. update-client_zh_CN.qm
   Qt 运行时加载的二进制翻译文件。它由 .ts 编译生成,不要手工编辑。

3. update-client.qrc
   Qt 资源文件。它会把 update-client_zh_CN.qm 编进 Launcher / Updater / MainApp,不需要把 .qm 单独暴露到安装目录。


日常编译
========

普通重新生成项目时,CMake 会自动执行 lrelease,把 update-client_zh_CN.ts 编译成 update-client_zh_CN.qm。

Visual Studio 里直接选择 x64 Release 或 x64 Debug,然后“全部重新生成”即可。

命令行等价操作:

```powershell
cmake --build --preset x64-release
```


新增界面文字后的流程
====================

如果代码里新增了 QObject::tr(...)、QCoreApplication::translate(...) 等需要翻译的文字,按下面步骤操作:

1. 更新 .ts 文件。

   Visual Studio

   在 CMake 目标里生成 update_client_lupdate。

   PowerShell

   ```powershell
   cd C:\Users\admin\Desktop\update-client
   cmake --build --preset x64-release --target update_client_lupdate
   ```

2. 打开 i18n/update-client_zh_CN.ts,补齐新增 source 对应的 translation。

   可以用 Qt Linguist 打开,也可以直接用文本编辑器编辑 XML。

3. 重新生成翻译和程序。

   Visual Studio

   “全部重新生成”即可。

   PowerShell

   ```powershell
   cmake --build --preset x64-release
   ```

   如果只想单独生成 .qm

   ```powershell
   cmake --build --preset x64-release --target update_client_translations
   ```


注意事项
========

1. 代码里不要直接写中文界面文字,统一写英文 source,再在 .ts 里翻译成中文。
2. .qm 已经通过 update-client.qrc 编进 exe,交付包里不需要单独放翻译文件。
3. 如果 Visual Studio 或 CMake 找不到 lupdate / lrelease,通常是 Qt 环境变量没配好。确认 CMAKE_PREFIX_PATH 或 Qt5_DIR 指向 Qt 5.15.2 的 msvc2019_64 目录。
4. update_client_lupdate 只在新增或修改 tr() 文案后需要手动生成;普通代码修改只需要正常重新生成项目。