Skip to content

Conversation

@GongHeng2017
Copy link
Contributor

@GongHeng2017 GongHeng2017 commented Dec 10, 2025

-- add translate for cpu.

Log: add feature
Task: https://pms.uniontech.com/task-view-384577.html

Summary by Sourcery

Add translation support for the CPU "Max Boost Clock" label and align the CPU table header configuration with the updated translations.

New Features:

  • Introduce a translatable "Max Boost Clock" label in the device base info translations.

Enhancements:

  • Adjust the CPU device table header to use a consistent, non-translated "Max Boost Clock" key alongside the new translation entry.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 10, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds translation support for the CPU "Max Boost Clock" label by including it in the generic device translation list and making the CPU table header use a non-translated literal for conditional display logic.

Class diagram for CPU translation handling changes

classDiagram
    class DeviceBaseInfo {
        +void generatorTranslate()
    }

    class DeviceCpu {
        -QStringList m_TableHeader
        +void loadTableHeader()
    }

    DeviceCpu --|> DeviceBaseInfo

    DeviceBaseInfo : generatorTranslate adds Max_Boost_Clock_translation
    DeviceCpu : loadTableHeader uses literal_Max_Boost_Clock_in_header
Loading

File-Level Changes

Change Details Files
Wire the CPU "Max Boost Clock" label into the translation system while keeping the conditional table header logic using a raw string key.
  • Extend the device base info translation generator to include the "Max Boost Clock" string using QObject::tr so it can be localized.
  • Change the CPU table header setup so the conditional header for special CPU types uses the plain string "Max Boost Clock" instead of the translated version, likely relying on the generic translation mapping instead of per-use tr().
deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp
deepin-devicemanager/src/DeviceManager/DeviceCpu.cpp

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

@deepin-ci-robot
Copy link

deepin pr auto review

我来帮你分析这个diff修改。这个修改主要涉及两处代码变更,都是关于字符串翻译的处理。

  1. 在 DeviceCpu.cpp 中:
- m_TableHeader.append(tr("Max Boost Clock"));
+ m_TableHeader.append("Max Boost Clock");
  1. 在 DeviceInfo.cpp 中:
 <<  tr("Processor")
+ << tr("Max Boost Clock");

以下是我的分析和建议:

  1. 代码逻辑问题:

    • 在 DeviceCpu.cpp 中移除了 tr() 函数调用,这会导致该字符串无法被翻译系统处理
    • 在 DeviceInfo.cpp 中添加了 tr() 调用,这是正确的做法
    • 这两处修改存在不一致性,应该统一处理方式
  2. 国际化支持问题:

    • tr() 是Qt的翻译函数,用于支持国际化
    • 移除 tr() 调用会导致该文本无法被翻译,降低软件的国际化支持
    • 建议保持使用 tr() 函数以确保所有用户界面文本都能被正确翻译
  3. 代码维护性:

    • 不一致的翻译处理方式会给后续维护带来困扰
    • 建议统一使用 tr() 函数处理所有用户可见的字符串

改进建议:

  1. 在 DeviceCpu.cpp 中恢复 tr() 调用:
m_TableHeader.append(tr("Max Boost Clock"));
  1. 确保所有用户界面文本都通过 tr() 函数处理,以保持代码的一致性和可维护性

  2. 如果确实不需要翻译某个特定字符串(比如技术术语),建议:

    • 添加注释说明原因
    • 或者在翻译文件中明确标记为不需要翻译

这样的修改将有助于:

  • 提高代码的一致性
  • 保持良好的国际化支持
  • 提高代码的可维护性
  • 确保所有用户界面文本都能被正确处理

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:

  • In DeviceCpu::loadTableHeader, "Max Boost Clock" is now a raw string while DeviceBaseInfo::generatorTranslate uses tr("Max Boost Clock"); consider using tr() consistently so the displayed header text is actually translated.
  • Since "Max Boost Clock" is now used in multiple places, consider extracting it into a shared constant or helper to avoid duplication and keep label changes synchronized across the UI.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `DeviceCpu::loadTableHeader`, `"Max Boost Clock"` is now a raw string while `DeviceBaseInfo::generatorTranslate` uses `tr("Max Boost Clock")`; consider using `tr()` consistently so the displayed header text is actually translated.
- Since `"Max Boost Clock"` is now used in multiple places, consider extracting it into a shared constant or helper to avoid duplication and keep label changes synchronized across the UI.

## Individual Comments

### Comment 1
<location> `deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp:1249` </location>
<code_context>
     <<  tr("Vendor") \
-    <<  tr("Processor");
+    <<  tr("Processor") \
+    << tr("Max Boost Clock");
 }

</code_context>

<issue_to_address>
**issue (bug_risk):** Check that always adding a translation for "Max Boost Clock" won't misalign any index-based mappings for devices where this column is not present.

In `generatorTranslate()` this translation is always appended, but `DeviceCpu::loadTableHeader()` only adds the "Max Boost Clock" column for `kSpecialCpuType1`. If any code assumes positional alignment between this translation list and the table headers, you could get off‑by‑one or incorrect labels when the column is absent. Consider applying the same condition here, or confirm that consumers don’t rely on strict index matching.
</issue_to_address>

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: GongHeng2017, max-lvs

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

@GongHeng2017
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Dec 10, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 7846ad2 into linuxdeepin:develop/eagle Dec 10, 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