Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements parsing of the IANA Language Subtag Registry to obtain mappings from individual languages to macro languages. The main purpose is to generate CSV files containing language mappings and variant-to-script relationships for localization support.
- Adds a new Gradle task
ParseLanguageSubtagRegistrythat parses IANA language subtag data - Generates two CSV files:
sublanguages.csvfor macro language mappings andvariant_to_script.csvfor variant-to-script mappings - Refactors
LocaleUtilsto load language mappings from CSV files instead of hardcoded data
Reviewed Changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ParseLanguageSubtagRegistry.java | New Gradle task for parsing IANA Language Subtag Registry and generating CSV mappings |
| variant_to_script.csv | Generated CSV file mapping script types to language variants |
| sublanguages.csv | Generated CSV file mapping macro languages to their sub-languages |
| LocaleUtils.java | Refactored to load language data from CSV files and added variant-to-script lookup |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
buildSrc/src/main/java/org/jackhuang/hmcl/gradle/l10n/ParseLanguageSubtagRegistry.java
Outdated
Show resolved
Hide resolved
buildSrc/src/main/java/org/jackhuang/hmcl/gradle/l10n/ParseLanguageSubtagRegistry.java
Outdated
Show resolved
Hide resolved
buildSrc/src/main/java/org/jackhuang/hmcl/gradle/l10n/ParseLanguageSubtagRegistry.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 9 out of 11 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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 10 out of 12 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if (currentValue != null) { | ||
| currentValue = currentValue + " " + line; |
There was a problem hiding this comment.
String concatenation in loop can be inefficient. Consider using StringBuilder, especially since this appears to be handling multi-line values that could span several iterations.
| updateItems(); | ||
| } else if (line.startsWith(" ")) { | ||
| if (currentValue != null) { | ||
| currentValue = currentValue + " " + line; |
There was a problem hiding this comment.
Continuation lines starting with ' ' should be trimmed before concatenation. The current code concatenates the entire line including leading spaces, which will result in multiple spaces in the value. Change to currentValue = currentValue + ' ' + line.trim();
| currentValue = currentValue + " " + line; | |
| currentValue = currentValue + " " + line.trim(); |
| /// Typically, it normalizes ISO 639 alpha-3 codes to ISO 639 alpha-2 codes. | ||
| public static @NotNull String normalizeLanguage(String language) { | ||
| return language.isEmpty() | ||
| ? "en" |
There was a problem hiding this comment.
The empty language defaulting to 'en' is embedded in multiple places (here and in getPreferredLanguage). Consider extracting this to a constant or single method to ensure consistency across the codebase.
| ? "en" | |
| ? DEFAULT_LANGUAGE_KEY |
No description provided.