@@ -632,10 +632,28 @@ final class ModListPageSkin extends SkinBase<ModListPage> {
|
||||
}).start();
|
||||
}
|
||||
|
||||
if (modTranslations != null && I18n.isUseChinese() && !modInfo.getName().equals(modTranslations.getName()))
|
||||
content.setTitle(modInfo.getName() + " (" + modTranslations.getName() + ")");
|
||||
else
|
||||
content.setTitle(modInfo.getName());
|
||||
|
||||
String displayName = modInfo.getName();
|
||||
if (modTranslations != null && I18n.isUseChinese()) {
|
||||
String chineseName = modTranslations.getName();
|
||||
if (StringUtils.containsChinese(chineseName)) {
|
||||
if (StringUtils.containsEmoji(chineseName)) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
chineseName.codePoints().forEach(ch -> {
|
||||
if (ch < 0x1F300 || ch > 0x1FAFF)
|
||||
builder.appendCodePoint(ch);
|
||||
});
|
||||
|
||||
chineseName = builder.toString().trim();
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(chineseName) && !displayName.equalsIgnoreCase(chineseName)) {
|
||||
displayName = displayName + " (" + chineseName + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
content.setTitle(displayName);
|
||||
|
||||
StringJoiner joiner = new StringJoiner(" | ");
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public final class StringUtils {
|
||||
builder.append(str, start, i);
|
||||
}
|
||||
builder.append(' ');
|
||||
i = whitespaceEnd ;
|
||||
i = whitespaceEnd;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -261,6 +261,19 @@ public final class StringUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private static boolean isVarNameStart(char ch) {
|
||||
return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == '_';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user