Skip to content

增强本地化支持#4379

Merged
Glavo merged 29 commits intoHMCL-dev:mainfrom
Glavo:i18n
Sep 3, 2025
Merged

增强本地化支持#4379
Glavo merged 29 commits intoHMCL-dev:mainfrom
Glavo:i18n

Conversation

@Glavo
Copy link
Copy Markdown
Member

@Glavo Glavo commented Sep 2, 2025

  1. 添加新的环境变量 HMCL_LANGUAGE 用于设置启动器语言;
  2. 实现 LocalizedText
  3. 实现基于语言环境的字体查找
  4. 优化对中文变体的支持

@Glavo Glavo linked an issue Sep 2, 2025 that may be closed by this pull request
@Glavo Glavo marked this pull request as ready for review September 3, 2025 07:23
@Glavo Glavo requested a review from Copilot September 3, 2025 07:23

This comment was marked as outdated.

@Glavo Glavo requested a review from Copilot September 3, 2025 12:52

This comment was marked as outdated.

@Glavo Glavo requested a review from Copilot September 3, 2025 13:49
@Glavo Glavo merged commit 6ab216d into HMCL-dev:main Sep 3, 2025
2 checks passed
@Glavo Glavo deleted the i18n branch September 3, 2025 13:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances localization support in HMCL by introducing improved Chinese language variants handling and font management capabilities.

  • Adds environment variable HMCL_LANGUAGE for launcher language configuration
  • Implements LocalizedText class for handling multilingual text content with JSON serialization
  • Introduces sophisticated locale candidate resolution with enhanced Chinese variants support
  • Implements locale-aware font loading system

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
LocaleUtilsTest.java Comprehensive test suite for locale utilities and Chinese variant handling
LocalizedText.java New class for managing localized text with JSON adapter support
LocaleUtils.java Core utility class for locale operations and Chinese language detection
DefaultResourceBundleControl.java Enhanced resource bundle control with optimized Chinese locale resolution
LocalesTest.java Test file removal (replaced by LocaleUtilsTest.java)
MinecraftWiki.java Updated to use new LocaleUtils methods for Chinese variant detection
Locales.java Refactored to use new locale utilities and added localized resource finding
I18n.java Simplified by delegating to new locale utilities
FontManager.java Enhanced with locale-aware font loading capabilities
HMCLGameLauncher.java Updated Chinese locale handling for Minecraft options

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +54 to +56
return null;
} else
return value;
Copy link

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getText method returns null when no localized value is found, but this could lead to null pointer exceptions. Consider returning an empty string or the first available value as a fallback instead.

Suggested change
return null;
} else
return value;
// Fallback: return the first available value if present
if (!localizedValues.isEmpty()) {
return localizedValues.values().iterator().next();
}
// If map is empty, return empty string
return "";
} else {
return value != null ? value : "";
}

Copilot uses AI. Check for mistakes.
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.

[Feature] 增强启动器的本地化支持

2 participants