Skip to content

Conversation

@Kakueeen
Copy link
Contributor

@Kakueeen Kakueeen commented Dec 17, 2025

The lrelease command in the CMake build process has been enhanced with
additional flags for better performance and output quality. The changes
include adding -compress flag to reduce the size of generated .qm files,
-nounfinished to exclude unfinished translations, and -removeidentical
to remove identical translations. Additionally, a new custom target
'generate_qm' has been added to ensure all .qm files are generated as
part of the build process.

Influence:

  1. Verify that .qm files are correctly generated during build
  2. Check that translation files are smaller in size due to compression
  3. Ensure unfinished translations are properly excluded from final
    output
  4. Test that identical translations are removed to avoid redundancy
  5. Confirm the generate_qm target builds all translation files as
    expected

fix: 优化 lrelease 命令并添加额外标志

CMake 构建过程中的 lrelease 命令已通过附加标志进行增强,以提高性
能和输出质量。更改包括添加 -compress 标志以减少生成的 .qm 文件大
小,-nounfinished 以排除未完成的翻译,以及 -removeidentical 以移除相同的
翻译。此外,新增了一个自定义目标 'generate_qm',以确保所有 .qm 文件作为
构建过程的一部分被生成。

Influence:

  1. 验证构建过程中 .qm 文件是否正确生成
  2. 检查翻译文件是否因压缩而体积变小
  3. 确保未完成的翻译被正确排除在最终输出之外
  4. 测试相同的翻译是否被移除以避免冗余
  5. 确认 generate_qm 目标按预期构建所有翻译文件

Summary by Sourcery

Optimize Qt translation generation in the CMake build by enhancing the lrelease invocation and ensuring all .qm files are built as part of the standard build process.

Build:

  • Update lrelease invocation in CMake to use compression and filtering flags for generated .qm files.
  • Add a generate_qm custom target that depends on all .qm outputs and is built by default.

The lrelease command in the CMake build process has been enhanced with
additional flags for better performance and output quality. The changes
include adding -compress flag to reduce the size of generated .qm files,
-nounfinished to exclude unfinished translations, and -removeidentical
to remove identical translations. Additionally, a new custom target
'generate_qm' has been added to ensure all .qm files are generated as
part of the build process.

Influence:
1. Verify that .qm files are correctly generated during build
2. Check that translation files are smaller in size due to compression
3. Ensure unfinished translations are properly excluded from final
output
4. Test that identical translations are removed to avoid redundancy
5. Confirm the generate_qm target builds all translation files as
expected

fix: 优化 lrelease 命令并添加额外标志

CMake 构建过程中的 lrelease 命令已通过附加标志进行增强,以提高性
能和输出质量。更改包括添加 -compress 标志以减少生成的 .qm 文件大
小,-nounfinished 以排除未完成的翻译,以及 -removeidentical 以移除相同的
翻译。此外,新增了一个自定义目标 'generate_qm',以确保所有 .qm 文件作为
构建过程的一部分被生成。

Influence:
1. 验证构建过程中 .qm 文件是否正确生成
2. 检查翻译文件是否因压缩而体积变小
3. 确保未完成的翻译被正确排除在最终输出之外
4. 测试相同的翻译是否被移除以避免冗余
5. 确认 generate_qm 目标按预期构建所有翻译文件
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 17, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Enhances the CMake lrelease-based translation build pipeline by adding optimization flags to the lrelease command and introducing a dedicated generate_qm target that ensures all .qm files are generated as part of the standard build.

Sequence diagram for build invoking generate_qm and lrelease with new flags

sequenceDiagram
    actor Dev
    participant BuildSystem as Build_system
    participant CMake as CMake_generator
    participant TargetGenerateQM as Target_generate_qm
    participant Lrelease as lrelease
    participant FileSystem as File_system

    Dev->>BuildSystem: Invoke build (e.g. make, ninja)
    BuildSystem->>CMake: Configure project
    CMake-->>BuildSystem: Generated build files with target generate_qm ALL

    Dev->>BuildSystem: Build ALL
    BuildSystem->>TargetGenerateQM: Execute custom target generate_qm

    loop For each .ts file
        TargetGenerateQM->>Lrelease: lrelease -compress -nounfinished -removeidentical TS_FILE -qm QM_FILE
        Lrelease->>FileSystem: Read TS_FILE
        Lrelease->>FileSystem: Write compressed QM_FILE without unfinished or identical translations
    end

    TargetGenerateQM-->>BuildSystem: All .qm files generated
    BuildSystem-->>Dev: Build finished including translation artifacts
Loading

Flow diagram for updated lrelease translation generation in CMake

flowchart TD
    subgraph Inputs
        TS1[".ts translation file 1"]
        TS2[".ts translation file 2"]
        TSn[".ts translation file N"]
    end

    subgraph CMake_Config["CMake configuration phase"]
        CFG_GEN_QM["Define custom commands to generate .qm from each .ts"]
        CFG_TARGET["Define custom target generate_qm with ALL and DEPENDS on all .qm files"]
    end

    subgraph Build_Phase["Build phase"]
        TARGET_GENERATE_QM["Custom target generate_qm"]
        LRELEASE_CMD["Run lrelease with flags -compress -nounfinished -removeidentical"]
    end

    TS1 --> CFG_GEN_QM
    TS2 --> CFG_GEN_QM
    TSn --> CFG_GEN_QM

    CFG_GEN_QM --> CFG_TARGET
    CFG_TARGET --> TARGET_GENERATE_QM

    TARGET_GENERATE_QM --> LRELEASE_CMD

    LRELEASE_CMD --> QM1["Compressed .qm file 1 (no unfinished, identical removed)"]
    LRELEASE_CMD --> QM2["Compressed .qm file 2 (no unfinished, identical removed)"]
    LRELEASE_CMD --> QMn["Compressed .qm file N (no unfinished, identical removed)"]

    subgraph Outputs
        QM1
        QM2
        QMn
    end
Loading

File-Level Changes

Change Details Files
Optimize lrelease invocation for .ts → .qm generation and wire all outputs into the build via a custom target.
  • Extend the lrelease command to include -compress, -nounfinished, and -removeidentical flags when generating .qm files from .ts sources.
  • Continue to emit one custom command per translation source and accumulate all generated .qm paths in a QM_FILES list.
  • Introduce a generate_qm custom target, built by default, that depends on all collected .qm files so translation generation is part of the normal build graph.
CMakeLists.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Consider using the Qt-provided lrelease executable (e.g., via Qt6::lrelease/Qt5::lrelease or a CMake variable) instead of a bare lrelease command to avoid path/portability issues across environments.
  • The -compress, -nounfinished, and -removeidentical flags may not be supported uniformly across all Qt versions; you may want to guard their usage with a version check or make them configurable so older toolchains don’t break.
  • Attaching generate_qm to ALL means .qm files will be regenerated on every normal build; if this is expensive, consider making it an opt-in target or tightening the dependencies to avoid unnecessary rebuilds.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider using the Qt-provided lrelease executable (e.g., via Qt6::lrelease/Qt5::lrelease or a CMake variable) instead of a bare `lrelease` command to avoid path/portability issues across environments.
- The `-compress`, `-nounfinished`, and `-removeidentical` flags may not be supported uniformly across all Qt versions; you may want to guard their usage with a version check or make them configurable so older toolchains don’t break.
- Attaching `generate_qm` to `ALL` means `.qm` files will be regenerated on every normal build; if this is expensive, consider making it an opt-in target or tightening the dependencies to avoid unnecessary rebuilds.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Kakueeen, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Kakueeen
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Dec 17, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 48e8660 into linuxdeepin:master Dec 17, 2025
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants