Skip to content

Fix: add translate for short cut#271

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
GongHeng2017:202605091402-master-fix
May 9, 2026
Merged

Fix: add translate for short cut#271
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
GongHeng2017:202605091402-master-fix

Conversation

@GongHeng2017
Copy link
Copy Markdown
Contributor

Add translate for short cut.

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-354843.html

@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

Git Diff 代码审查报告

整体评估

本次提交主要涉及翻译文件(.ts)的更新和一个新增的lupdate.sh脚本。这些更改主要是更新了翻译字符串的位置信息和新增了一些未翻译的字符串。整体代码质量良好,但有一些可以改进的地方。

1. lupdate.sh 脚本审查

语法逻辑

  • 脚本语法正确,没有明显的语法错误
  • 使用了正确的shebang #!/bin/bash
  • 包含了适当的版权声明和许可证信息

代码质量

  • 脚本功能明确,用于更新翻译文件
  • 每个命令都使用了相同的参数结构,保持了一致性
  • 缺少错误处理机制,如果lupdate命令失败,脚本会继续执行

代码性能

  • 脚本顺序执行多个lupdate命令,没有并行处理
  • 对于多个翻译文件,可以考虑使用循环结构减少重复代码

代码安全

  • 脚本使用了相对路径 ./reader./translations,依赖执行位置
  • 没有检查lupdate命令是否存在
  • 没有检查源目录和翻译目录是否存在

改进建议

#!/bin/bash

# SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later

# 检查lupdate命令是否存在
if ! command -v lupdate &> /dev/null; then
    echo "Error: lupdate command not found. Please install Qt Linguist tools."
    exit 1
fi

# 检查源目录是否存在
if [ ! -d "./reader" ]; then
    echo "Error: Source directory './reader' not found."
    exit 1
fi

# 检查翻译目录是否存在
if [ ! -d "./translations" ]; then
    echo "Error: Translation directory './translations' not found."
    exit 1
fi

# 定义翻译文件列表
translation_files=(
    "deepin-reader.ts"
    "deepin-reader_zh_CN.ts"
    "deepin-reader_zh_TW.ts"
    "deepin-reader_zh_HK.ts"
    "deepin-reader_ug.ts"
    "deepin-reader_bo.ts"
)

# 更新所有翻译文件
for file in "${translation_files[@]}"; do
    echo "Updating $file..."
    if ! lupdate ./reader -ts -no-obsolete "./translations/$file"; then
        echo "Error: Failed to update $file"
        exit 1
    fi
done

echo "All translation files updated successfully."

2. 翻译文件(.ts)审查

语法逻辑

  • 所有翻译文件的XML格式正确
  • 新增的字符串使用了正确的<message><translation>标签
  • 未翻译的字符串正确使用了type="unfinished"属性

代码质量

  • 新增的字符串位置信息已正确更新
  • 翻译文件保持了良好的格式和结构
  • 所有翻译文件都添加了XML声明和DOCTYPE声明,提高了兼容性

代码性能

  • 翻译文件本身不涉及性能问题

代码安全

  • 翻译文件没有安全问题

改进建议

  1. 对于未翻译的字符串,建议添加注释说明上下文,以便翻译人员理解
  2. 考虑为翻译文件添加版本控制信息,便于追踪更改
  3. 对于新增的字符串,建议在源代码中添加注释说明其用途

3. 具体问题

lupdate.sh

  1. 缺少错误处理
  2. 使用硬编码的文件列表,不够灵活
  3. 没有提供帮助信息

翻译文件

  1. 部分新增字符串未翻译(标记为type="unfinished"
  2. 缺少上下文信息
  3. 部分翻译文件中存在重复的行号信息(如deepin-reader_bo.ts中的"Scroll up one line"和"Scroll down one line")

4. 总体建议

  1. 为lupdate.sh脚本添加错误处理和帮助信息
  2. 考虑使用循环结构处理多个翻译文件
  3. 为未翻译的字符串添加上下文信息
  4. 确保所有翻译文件保持一致的格式和结构
  5. 考虑添加自动化测试,验证翻译文件的格式和完整性

5. 优先级

  1. 高优先级:添加错误处理和检查机制到lupdate.sh脚本
  2. 中优先级:为未翻译的字符串添加上下文信息
  3. 低优先级:优化脚本结构,减少重复代码

总体而言,本次提交的代码质量良好,主要是一些改进空间,没有严重的问题需要立即修复。

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GongHeng2017, 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

@GongHeng2017
Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot
Copy link
Copy Markdown
Contributor

deepin-bot Bot commented May 9, 2026

This pr force merged! (status: unstable)

@deepin-bot deepin-bot Bot merged commit d8e8be3 into linuxdeepin:master May 9, 2026
10 of 11 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