fix: translation not loaded if language code not fully matched#351
fix: translation not loaded if language code not fully matched#351BLumia merged 1 commit intolinuxdeepin:masterfrom
Conversation
修正当系统语言代码与翻译资源的语言代码不完全匹配时(例如资源文件的语 言代码中不包括地区代码部分),翻译资源不会被加载的问题. Log:
deepin pr auto review代码审查意见:
综上所述,建议对代码进行重构,提取公共函数,增加错误处理和日志记录,移除未使用的变量,以及使用配置文件或环境变量来管理路径,以提高代码质量、可维护性和可读性。 |
Reviewer's GuideThis PR refactors translation loading across multiple plugins to use QTranslator::load(QLocale, ...) for better locale matching, adds conditional installation based on load success, introduces logging for success/failure, and handles cleanup when loading fails. Class Diagram of Modified Classes for Translation HandlingclassDiagram
class NetworkInitialization {
+installUserTranslator(const QString &json): bool
}
class NetworkController {
-m_translator: QTranslator*
+installTranslator(const QString &locale): void
}
class HotspotPlugin {
+HotspotPlugin(QObject *parent)
}
class NetworkPlugin {
+NetworkPlugin(QObject *parent)
}
class NetworkModule {
+installTranslator(const QString &locale): void
}
note "The methods/constructors listed are updated to use QTranslator::load(QLocale, ...) for improved locale matching, conditional installation, and logging."
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, caixr23 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 |
There was a problem hiding this comment.
Hey @BLumia - I've reviewed your changes - here's some feedback:
- Consider refactoring the repeated QTranslator::load + installTranslator logic into a shared helper to avoid duplicating the same code across modules.
- Make sure you consistently remove or delete any existing QTranslator before installing a new one (and on failure) to prevent memory leaks or duplicate translations.
- Standardize on one logging API (e.g. qCInfo/qCWarning with proper categories) instead of mixing qInfo/qWarning and qCInfo/qCWarning for more consistent diagnostics.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
修正当系统语言代码与翻译资源的语言代码不完全匹配时(例如资源文件的语言代码中不包括地区代码部分),翻译资源不会被加载的问题.
Summary by Sourcery
Improve translation loading across plugins to handle partial locale codes and provide logging on success or failure.
Bug Fixes:
Enhancements: