Skip to content

优化模组中文译名展示方式#4636

Merged
Glavo merged 2 commits intoHMCL-dev:mainfrom
Glavo:mod-chinese-name
Oct 9, 2025
Merged

优化模组中文译名展示方式#4636
Glavo merged 2 commits intoHMCL-dev:mainfrom
Glavo:mod-chinese-name

Conversation

@Glavo
Copy link
Copy Markdown
Member

@Glavo Glavo commented Oct 9, 2025

  1. 隐藏不包含中文字符的译名
  2. 过滤译名中的 Emoji

Copilot AI review requested due to automatic review settings October 9, 2025 08:29
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 optimizes the display of Chinese translations for mod names by filtering out translations that don't contain Chinese characters and removing emojis from translation text.

  • Added a utility method to detect emoji characters in strings
  • Updated mod list display logic to show Chinese translations only when they contain Chinese characters
  • Implemented emoji filtering for Chinese translation names

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
StringUtils.java Added containsEmoji method to detect emoji characters using Unicode ranges
ModListPageSkin.java Enhanced mod name display logic to filter non-Chinese translations and remove emojis

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

Comment on lines +264 to +274
public static boolean containsEmoji(String str) {
for (int i = 0; i < str.length(); ) {
int ch = str.codePointAt(i);

if (ch >= 0x1F300 && ch <= 0x1FAFF)
return true;

i += Character.charCount(ch);
}

return false;
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

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

The emoji detection range 0x1F300-0x1FAFF may not cover all emoji characters. Consider using a more comprehensive approach or documenting the specific Unicode blocks this range covers (e.g., Miscellaneous Symbols and Pictographs, Emoticons, etc.).

Suggested change
public static boolean containsEmoji(String str) {
for (int i = 0; i < str.length(); ) {
int ch = str.codePointAt(i);
if (ch >= 0x1F300 && ch <= 0x1FAFF)
return true;
i += Character.charCount(ch);
}
return false;
// Emoji regex pattern covering major Unicode emoji blocks
private static final java.util.regex.Pattern EMOJI_PATTERN = java.util.regex.Pattern.compile(
"[\u203C-\u3299\u00A9\u00AE\u2122\u2139\u2194-\u21AA\u231A-\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA" +
"\u24C2\u25AA-\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614-\u2615\u2618\u261D\u2620" +
"\u2622-\u2623\u2626\u262A\u262E-\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F-\u2660\u2663\u2665-\u2666" +
"\u2668\u267B\u267F\u2692-\u2697\u2699\u269B-\u269C\u26A0-\u26A1\u26AA-\u26AB\u26B0-\u26B1\u26BD-\u26BE" +
"\u26C4-\u26C5\u26C8\u26CE-\u26CF\u26D1\u26D3-\u26D4\u26E9-\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD" +
"\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733-\u2734\u2744\u2747\u274C" +
"\u274E\u2753-\u2755\u2757\u2763-\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934-\u2935\u2B05-\u2B07" +
"\u2B1B-\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299" +
"\uD83C[\uDC04\uDCCF\uDD70-\uDD71\uDD7E-\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01-\uDE02\uDE1A\uDE2F" +
"\uDE32-\uDE3A\uDE50-\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDF9F\uDFA0-\uDFCA" +
"\uDFCF-\uDFD3\uDFE0-\uDFF0]" +
"|\uD83D[\uDC00-\uDE4F\uDE80-\uDEF6]" +
"|\uD83E[\uDD00-\uDDFF\uDE70-\uDEFF]" +
")"
);
public static boolean containsEmoji(String str) {
return EMOJI_PATTERN.matcher(str).find();

Copilot uses AI. Check for mistakes.
@HMCL-dev HMCL-dev deleted a comment from Copilot AI Oct 9, 2025
@Glavo Glavo merged commit c8edf4b into HMCL-dev:main Oct 9, 2025
2 checks passed
@Glavo Glavo deleted the mod-chinese-name branch October 9, 2025 08:34
@burningtnt
Copy link
Copy Markdown
Member

或许应当在 mod_data.txt 翻译文件被创建时完成格式化,而不是在运行时替换文本?

@Glavo
Copy link
Copy Markdown
Member Author

Glavo commented Oct 9, 2025

或许应当在 mod_data.txt 翻译文件被创建时完成格式化,而不是在运行时替换文本?

现在新的显示方式仅适用于模组列表页面,下载页面还是会显示 Emoji。如果决定要对所有场合都过滤掉 Emoji,那可以考虑直接对 mod_data.txt 进行处理。

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