Skip to content

Commit

Permalink
fix: Unable to use "/qb list" due to local translation
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyDynamic committed Dec 9, 2023
1 parent 8f9332e commit fb392d8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private static int getLang(ServerCommandSource commandSource) {
}

private static int setLang(ServerCommandSource commandSource, String lang) {
commandSource.sendMessage(Text.of(String.format(tr("quickbackupmulti.lang.get"), Config.INSTANCE.getLang())));
commandSource.sendMessage(Text.of(String.format(tr("quickbackupmulti.lang.set"), lang)));
Translate.handleResourceReload(lang);
Config.INSTANCE.setLang(lang);
return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static int make(ServerCommandSource commandSource, int slot, String desc)
}

public static MutableText list() {
MutableText resultText = Text.literal("§l§d[槽位信息]");
MutableText resultText = Text.literal(tr("quickbackupmulti.list_backup.title"));
long totalBackupSizeB = 0;
for (int j=1;j<=Config.INSTANCE.getNumOfSlot();j++) {
try {
Expand All @@ -140,30 +140,28 @@ public static MutableText list() {
reader.close();
int finalJ = j;
backText.styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/qb back " + finalJ)))
.styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.of(String.format(tr("quickbackupmulti.list_backup.slot.restore", finalJ))))));
.styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.of(String.format(tr("quickbackupmulti.list_backup.slot.restore"), finalJ)))));
deleteText.styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/qb delete " + finalJ)))
.styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.of(String.format(tr("quickbackupmulti.list_backup.slot.delete", finalJ))))));
.styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.of(String.format(tr("quickbackupmulti.list_backup.slot.delete"), finalJ)))));
String desc = result.desc;
if (Objects.equals(result.desc, "")) desc = "§8空";
if (Objects.equals(result.desc, "")) desc = tr("quickbackupmulti.empty_comment");
long backupSizeB = getDirSize(backupDir.resolve("Slot" + j).toFile());
totalBackupSizeB += backupSizeB;
double backupSizeMB = (double) backupSizeB / FileUtils.ONE_MB;
double backupSizeGB = (double) backupSizeB / FileUtils.ONE_GB;
String sizeString = (backupSizeMB >= 1000) ? String.format("%.2f GB", backupSizeGB) : String.format("%.2fMB", backupSizeMB);
resultText.append("\n" + String.format(tr("quickbackupmulti.list_backup.title", finalJ)))
resultText.append("\n" + String.format(tr("quickbackupmulti.list_backup.slot.header"), finalJ) + " ")
.append(backText)
.append(deleteText)
.append("§2§l" + sizeString)
.append(String.format("§r日期: %s; 注释: %s", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(result.timestamp), desc));
} catch (FileNotFoundException e) {
resultText.append(Text.literal("\n"+ String.format(tr("quickbackupmulti.list_backup.title" + " §2[▷] §c[×] §rNone"))));
.append(String.format(tr("quickbackupmulti.list_backup.slot.info"), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(result.timestamp), desc));
} catch (IOException e) {
throw new RuntimeException(e);
resultText.append(Text.literal("\n"+ String.format(tr("quickbackupmulti.list_backup.slot.header"), j) + " §2[▷] §c[×] §rNone"));
}
}
double totalBackupSizeMB = (double) totalBackupSizeB / FileUtils.ONE_MB;
double totalBackupSizeGB = (double) totalBackupSizeB / FileUtils.ONE_GB;
String sizeString = (totalBackupSizeMB >= 1000) ? String.format("%.2f GB", totalBackupSizeGB) : String.format("%.2fMB", totalBackupSizeMB);
String sizeString = (totalBackupSizeMB >= 1000) ? String.format("%.2fGB", totalBackupSizeGB) : String.format("%.2fMB", totalBackupSizeMB);
resultText.append("\n" + String.format(tr("quickbackupmulti.list_backup.slot.total_space"), sizeString));
return resultText;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/quickbackupmulti/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ quickbackupmulti:
restore: Click to restore to slot §6%s§r
delete: Click to delete slot §6%s§r
total_space: "Total space consumed: §a%s§r"
info: " §rDate: %s; Desc: %s"

restore:
countdown:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/quickbackupmulti/lang/zh_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ quickbackupmulti:
restore: 点击回档至槽位§6%s§r
delete: 点击删除槽位§6%s§r
total_space: "备份总占用空间: §a%s§r"
info: " §r日期: %s; 注释: %s"

restore:
countdown:
Expand Down

0 comments on commit fb392d8

Please sign in to comment.