Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the download speed formatting logic by moving it from inline code into a centralized Translator utility. The purpose is to enable locale-specific formatting of speed values and improve code maintainability by eliminating duplication.
Key changes:
- Added a new
formatSpeed(long bytes)method to theTranslatorclass andI18nutility - Refactored
TaskExecutorDialogPaneto use the new centralized formatting method instead of inline speed calculation - Extended
Translator_en_Qabsto apply translation to formatted speed strings
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Translator.java | Implements core speed formatting logic with KiB/s and MiB/s unit conversions |
| I18n.java | Adds public API method to delegate speed formatting to the translator |
| Translator_en_Qabs.java | Overrides formatSpeed to apply translation to the formatted output |
| TaskExecutorDialogPane.java | Replaces inline speed formatting code with call to I18n.formatSpeed |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| import org.jackhuang.hmcl.download.RemoteVersion; | ||
| import org.jackhuang.hmcl.util.i18n.SupportedLocale; | ||
|
|
||
| import java.text.DecimalFormat; |
There was a problem hiding this comment.
The DecimalFormat import is unused. This import should be removed as the code uses String.format() instead.
| import java.text.DecimalFormat; |
| speed /= 1024; | ||
| unit = "KiB/s"; | ||
| } | ||
| if (speed > 1024) { |
There was a problem hiding this comment.
The second condition should check if speed >= 1024 instead of speed > 1024 to ensure consistent unit boundaries. A speed of exactly 1024 KiB/s should be displayed as 1.0 MiB/s, not 1024.0 KiB/s.
| if (speed > 1024) { | |
| if (speed >= 1024) { |
|
这个 PR 里涉及的文本能否实现 i18n?一些斯拉夫语言(如俄语、乌克兰语)是用西里尔字母表示这些单位的。 |
可以,使用 你可以把对应的文本给我,我实现一下这些语言的本地化。 |
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
No description provided.