Optimize Chinese Localization, Add Time Units, and Fix Italic Bug (#796)

* add time unit to language file

* Fixed a bug where the font following a blocktype name was incorrectly rendered in italics.

* Collected time unit abbreviations

* Update pom.xml

---------

Co-authored-by: Intelli <6790859+Intelli@users.noreply.github.com>
This commit is contained in:
Halogly 2025-09-10 00:13:41 +08:00 committed by GitHub
parent 8b3e37774a
commit abb0ece3e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 156 additions and 147 deletions

View file

@ -1,25 +1,18 @@
package net.coreprotect.database.lookup;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Locale;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.command.CommandSender;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.language.Phrase;
import net.coreprotect.language.Selector;
import net.coreprotect.listener.channel.PluginChannelListener;
import net.coreprotect.utility.ChatUtils;
import net.coreprotect.utility.Color;
import net.coreprotect.utility.EntityUtils;
import net.coreprotect.utility.MaterialUtils;
import net.coreprotect.utility.StringUtils;
import net.coreprotect.utility.Util;
import net.coreprotect.utility.WorldUtils;
import net.coreprotect.utility.*;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.command.CommandSender;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Locale;
public class BlockLookup {
@ -157,7 +150,7 @@ public class BlockLookup {
// resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Color.WHITE + "No block data found at " + Color.ITALIC + "x" + x + "/y" + y + "/z" + z + ".";
resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_DATA_LOCATION, Selector.FIRST);
if (!blockName.equals("air") && !blockName.equals("cave_air")) {
resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_DATA, Color.ITALIC + block.getType().name().toLowerCase(Locale.ROOT)) + "\n";
resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_DATA, Color.ITALIC + block.getType().name().toLowerCase(Locale.ROOT) + Color.WHITE) + "\n";
}
}
}

View file

@ -223,6 +223,7 @@ public class Language {
phrases.put(Phrase.TIME_MINUTES, "{0} {minute|minutes}");
phrases.put(Phrase.TIME_MONTHS, "{0} {month|months}");
phrases.put(Phrase.TIME_SECONDS, "{0} {second|seconds}");
phrases.put(Phrase.TIME_UNITS, "{/m|/h|/d}");
phrases.put(Phrase.TIME_WEEKS, "{0} {week|weeks}");
phrases.put(Phrase.TIME_YEARS, "{0} {year|years}");
phrases.put(Phrase.UPDATE_ERROR, "An error occurred while checking for updates.");

View file

@ -1,15 +1,15 @@
package net.coreprotect.language;
import net.coreprotect.utility.ChatMessage;
import net.coreprotect.utility.Color;
import net.coreprotect.utility.StringUtils;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.coreprotect.utility.ChatMessage;
import net.coreprotect.utility.Color;
import net.coreprotect.utility.StringUtils;
public enum Phrase {
ACTION_NOT_SUPPORTED,
@ -206,6 +206,7 @@ public enum Phrase {
TIME_MINUTES,
TIME_MONTHS,
TIME_SECONDS,
TIME_UNITS,
TIME_WEEKS,
TIME_YEARS,
UPDATE_ERROR,

View file

@ -1,15 +1,15 @@
package net.coreprotect.utility;
import net.coreprotect.language.Phrase;
import net.coreprotect.language.Selector;
import org.bukkit.command.ConsoleCommandSender;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import org.bukkit.command.ConsoleCommandSender;
import net.coreprotect.language.Phrase;
public class ChatUtils {
private ChatUtils() {
@ -137,24 +137,26 @@ public class ChatUtils {
timeSince = 0.00;
}
DecimalFormat decimalFormat = new DecimalFormat("0.00");
// minutes
timeSince = timeSince / 60;
if (timeSince < 60.0) {
message.append(Phrase.build(Phrase.LOOKUP_TIME, new DecimalFormat("0.00").format(timeSince) + "/m"));
message.append(Phrase.build(Phrase.LOOKUP_TIME, decimalFormat.format(timeSince) + Phrase.build(Phrase.TIME_UNITS, Selector.FIRST)));
}
// hours
if (message.length() == 0) {
timeSince = timeSince / 60;
if (timeSince < 24.0) {
message.append(Phrase.build(Phrase.LOOKUP_TIME, new DecimalFormat("0.00").format(timeSince) + "/h"));
message.append(Phrase.build(Phrase.LOOKUP_TIME, decimalFormat.format(timeSince) + Phrase.build(Phrase.TIME_UNITS, Selector.SECOND)));
}
}
// days
if (message.length() == 0) {
timeSince = timeSince / 24;
message.append(Phrase.build(Phrase.LOOKUP_TIME, new DecimalFormat("0.00").format(timeSince) + "/d"));
message.append(Phrase.build(Phrase.LOOKUP_TIME, decimalFormat.format(timeSince) + Phrase.build(Phrase.TIME_UNITS, Selector.THIRD)));
}
if (component) {