Skip to content

Commit abb0ece

Browse files
HaloglyIntelli
andauthored
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 <[email protected]>
1 parent 8b3e377 commit abb0ece

File tree

7 files changed

+156
-147
lines changed

7 files changed

+156
-147
lines changed

lang/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ TIME_HOURS: "{0} {hour|hours}"
194194
TIME_MINUTES: "{0} {minute|minutes}"
195195
TIME_MONTHS: "{0} {month|months}"
196196
TIME_SECONDS: "{0} {second|seconds}"
197+
TIME_UNITS: "{/m|/h|/d}"
197198
TIME_WEEKS: "{0} {week|weeks}"
198199
TIME_YEARS: "{0} {year|years}"
199200
UPDATE_ERROR: "An error occurred while checking for updates."

lang/zh-cn.yml

Lines changed: 130 additions & 119 deletions
Large diffs are not rendered by default.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,4 @@
306306
<scope>test</scope>
307307
</dependency>
308308
</dependencies>
309-
</project>
309+
</project>

src/main/java/net/coreprotect/database/lookup/BlockLookup.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
package net.coreprotect.database.lookup;
22

3-
import java.sql.ResultSet;
4-
import java.sql.Statement;
5-
import java.util.Locale;
6-
7-
import org.bukkit.Material;
8-
import org.bukkit.block.BlockState;
9-
import org.bukkit.command.CommandSender;
10-
113
import net.coreprotect.config.ConfigHandler;
124
import net.coreprotect.database.statement.UserStatement;
135
import net.coreprotect.language.Phrase;
146
import net.coreprotect.language.Selector;
157
import net.coreprotect.listener.channel.PluginChannelListener;
16-
import net.coreprotect.utility.ChatUtils;
17-
import net.coreprotect.utility.Color;
18-
import net.coreprotect.utility.EntityUtils;
19-
import net.coreprotect.utility.MaterialUtils;
20-
import net.coreprotect.utility.StringUtils;
21-
import net.coreprotect.utility.Util;
22-
import net.coreprotect.utility.WorldUtils;
8+
import net.coreprotect.utility.*;
9+
import org.bukkit.Material;
10+
import org.bukkit.block.BlockState;
11+
import org.bukkit.command.CommandSender;
12+
13+
import java.sql.ResultSet;
14+
import java.sql.Statement;
15+
import java.util.Locale;
2316

2417
public class BlockLookup {
2518

@@ -157,7 +150,7 @@ else if (commandSender.hasPermission("coreprotect.coreprotect")) {
157150
// resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Color.WHITE + "No block data found at " + Color.ITALIC + "x" + x + "/y" + y + "/z" + z + ".";
158151
resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_DATA_LOCATION, Selector.FIRST);
159152
if (!blockName.equals("air") && !blockName.equals("cave_air")) {
160-
resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_DATA, Color.ITALIC + block.getType().name().toLowerCase(Locale.ROOT)) + "\n";
153+
resultText = Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.NO_DATA, Color.ITALIC + block.getType().name().toLowerCase(Locale.ROOT) + Color.WHITE) + "\n";
161154
}
162155
}
163156
}

src/main/java/net/coreprotect/language/Language.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ public static void loadPhrases() {
223223
phrases.put(Phrase.TIME_MINUTES, "{0} {minute|minutes}");
224224
phrases.put(Phrase.TIME_MONTHS, "{0} {month|months}");
225225
phrases.put(Phrase.TIME_SECONDS, "{0} {second|seconds}");
226+
phrases.put(Phrase.TIME_UNITS, "{/m|/h|/d}");
226227
phrases.put(Phrase.TIME_WEEKS, "{0} {week|weeks}");
227228
phrases.put(Phrase.TIME_YEARS, "{0} {year|years}");
228229
phrases.put(Phrase.UPDATE_ERROR, "An error occurred while checking for updates.");

src/main/java/net/coreprotect/language/Phrase.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package net.coreprotect.language;
22

3+
import net.coreprotect.utility.ChatMessage;
4+
import net.coreprotect.utility.Color;
5+
import net.coreprotect.utility.StringUtils;
6+
37
import java.util.Arrays;
48
import java.util.HashSet;
59
import java.util.Set;
610
import java.util.regex.Matcher;
711
import java.util.regex.Pattern;
812

9-
import net.coreprotect.utility.ChatMessage;
10-
import net.coreprotect.utility.Color;
11-
import net.coreprotect.utility.StringUtils;
12-
1313
public enum Phrase {
1414

1515
ACTION_NOT_SUPPORTED,
@@ -206,6 +206,7 @@ public enum Phrase {
206206
TIME_MINUTES,
207207
TIME_MONTHS,
208208
TIME_SECONDS,
209+
TIME_UNITS,
209210
TIME_WEEKS,
210211
TIME_YEARS,
211212
UPDATE_ERROR,

src/main/java/net/coreprotect/utility/ChatUtils.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package net.coreprotect.utility;
22

3+
import net.coreprotect.language.Phrase;
4+
import net.coreprotect.language.Selector;
5+
import org.bukkit.command.ConsoleCommandSender;
6+
37
import java.text.DecimalFormat;
48
import java.text.DecimalFormatSymbols;
59
import java.text.SimpleDateFormat;
610
import java.util.Date;
711
import java.util.Locale;
812

9-
import org.bukkit.command.ConsoleCommandSender;
10-
11-
import net.coreprotect.language.Phrase;
12-
1313
public class ChatUtils {
1414

1515
private ChatUtils() {
@@ -137,24 +137,26 @@ public static String getTimeSince(long resultTime, long currentTime, boolean com
137137
timeSince = 0.00;
138138
}
139139

140+
DecimalFormat decimalFormat = new DecimalFormat("0.00");
141+
140142
// minutes
141143
timeSince = timeSince / 60;
142144
if (timeSince < 60.0) {
143-
message.append(Phrase.build(Phrase.LOOKUP_TIME, new DecimalFormat("0.00").format(timeSince) + "/m"));
145+
message.append(Phrase.build(Phrase.LOOKUP_TIME, decimalFormat.format(timeSince) + Phrase.build(Phrase.TIME_UNITS, Selector.FIRST)));
144146
}
145147

146148
// hours
147149
if (message.length() == 0) {
148150
timeSince = timeSince / 60;
149151
if (timeSince < 24.0) {
150-
message.append(Phrase.build(Phrase.LOOKUP_TIME, new DecimalFormat("0.00").format(timeSince) + "/h"));
152+
message.append(Phrase.build(Phrase.LOOKUP_TIME, decimalFormat.format(timeSince) + Phrase.build(Phrase.TIME_UNITS, Selector.SECOND)));
151153
}
152154
}
153155

154156
// days
155157
if (message.length() == 0) {
156158
timeSince = timeSince / 24;
157-
message.append(Phrase.build(Phrase.LOOKUP_TIME, new DecimalFormat("0.00").format(timeSince) + "/d"));
159+
message.append(Phrase.build(Phrase.LOOKUP_TIME, decimalFormat.format(timeSince) + Phrase.build(Phrase.TIME_UNITS, Selector.THIRD)));
158160
}
159161

160162
if (component) {

0 commit comments

Comments
 (0)