Fix: [translate] Translation is incorrect#585
Fix: [translate] Translation is incorrect#585deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom
Conversation
-- Translation method does not conform to standards -- Adjust translation Log: fix issue Task: https://pms.uniontech.com/task-view-384577.html
Reviewer's GuideThis PR standardizes CPU-related UI translations by switching from a custom translateStr helper to Qt's native tr() for all relevant strings and adds a helper script to regenerate Qt translation files for multiple locales. Flow diagram for lupdate translation regeneration scriptflowchart TD
A[Developer runs lupdate_sh] --> B[Invoke lupdate on src]
B --> C[Generate deepin-devicemanager_ts]
B --> D[Generate deepin-devicemanager_zh_CN_ts]
B --> E[Generate deepin-devicemanager_zh_TW_ts]
B --> F[Generate deepin-devicemanager_zh_HK_ts]
B --> G[Generate deepin-devicemanager_ug_ts]
B --> H[Generate deepin-devicemanager_bo_ts]
C --> I[Updated translation sources]
D --> I
E --> I
F --> I
G --> I
H --> I
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review我来对这个diff进行代码审查:
改进建议:
#!/bin/bash
set -e
# SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later
SRC_DIR="./src"
TRANS_DIR="../translations"
# 检查目录是否存在
if [ ! -d "$SRC_DIR" ]; then
echo "Source directory $SRC_DIR does not exist"
exit 1
fi
if [ ! -d "$TRANS_DIR" ]; then
echo "Translation directory $TRANS_DIR does not exist"
exit 1
fi
# 更新翻译文件
lupdate "$SRC_DIR" -ts -no-obsolete "$TRANS_DIR/deepin-devicemanager.ts"
lupdate "$SRC_DIR" -ts -no-obsolete "$TRANS_DIR/deepin-devicemanager_zh_CN.ts"
lupdate "$SRC_DIR" -ts -no-obsolete "$TRANS_DIR/deepin-devicemanager_zh_TW.ts"
lupdate "$SRC_DIR" -ts -no-obsolete "$TRANS_DIR/deepin-devicemanager_zh_HK.ts"
lupdate "$SRC_DIR" -ts -no-obsolete "$TRANS_DIR/deepin-devicemanager_ug.ts"
lupdate "$SRC_DIR" -ts -no-obsolete "$TRANS_DIR/deepin-devicemanager_bo.ts"
void DeviceCpu::getTrNumber()
{
// 使用初始化列表方式
static const QMap<int, QString> numberMap = {
{1, tr("One")}, {2, tr("Two")}, {4, tr("Four")},
// ... 其他映射 ...
};
m_trNumber = numberMap;
}
总体来说,这个改动是积极的,使用Qt标准的tr()函数更有利于代码维护和国际化支持。主要的改进空间在于脚本的安全性和错误处理,以及数字翻译的实现方式。 |
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- In
getTrNumber(), since the only change is swappingtranslateStrfortr, this might be a good opportunity to replace the large hard-coded map of spelled-out numbers with a more compact helper (e.g., a generic number-to-text routine or at least a data-driven table) to reduce repetition and maintenance overhead. - The new
lupdate.shscript hardcodes multiple nearly identicallupdatecalls and assumes it is run from a specific directory; consider iterating over the translation files in a loop and basing paths on$(dirname "$0")to make the script more maintainable and robust to different working directories.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `getTrNumber()`, since the only change is swapping `translateStr` for `tr`, this might be a good opportunity to replace the large hard-coded map of spelled-out numbers with a more compact helper (e.g., a generic number-to-text routine or at least a data-driven table) to reduce repetition and maintenance overhead.
- The new `lupdate.sh` script hardcodes multiple nearly identical `lupdate` calls and assumes it is run from a specific directory; consider iterating over the translation files in a loop and basing paths on `$(dirname "$0")` to make the script more maintainable and robust to different working directories.
## Individual Comments
### Comment 1
<location> `deepin-devicemanager/lupdate.sh:7-12` </location>
<code_context>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+lupdate ./src -ts -no-obsolete ../translations/deepin-devicemanager.ts
+lupdate ./src -ts -no-obsolete ../translations/deepin-devicemanager_zh_CN.ts
+lupdate ./src -ts -no-obsolete ../translations/deepin-devicemanager_zh_TW.ts
+lupdate ./src -ts -no-obsolete ../translations/deepin-devicemanager_zh_HK.ts
+lupdate ./src -ts -no-obsolete ../translations/deepin-devicemanager_ug.ts
+lupdate ./src -ts -no-obsolete ../translations/deepin-devicemanager_bo.ts
\ No newline at end of file
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Script assumes a fixed working directory and lacks basic safety options.
This will fail if run outside the project root, and failed `lupdate` calls won’t stop the rest. Consider adding `set -euo pipefail`, resolving paths relative to the script location (e.g. `SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"` then `"$SCRIPT_DIR"/src` and `"$SCRIPT_DIR"/../translations/...`), and consistently quoting paths to handle spaces/odd characters.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
2e60f5f
into
linuxdeepin:develop/eagle
-- Translation method does not conform to standards -- Adjust translation
Log: fix issue
Task: https://pms.uniontech.com/task-view-384577.html
Summary by Sourcery
Standardize CPU-related UI translations and add tooling support for updating translation files.
Enhancements:
Build: