Skip to content

Commit

Permalink
Translate to english
Browse files Browse the repository at this point in the history
  • Loading branch information
acrylic-style committed Dec 5, 2024
1 parent a6c1aac commit 0a35255
Show file tree
Hide file tree
Showing 13 changed files with 874 additions and 338 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.azisaba.spicyAzisaBan.bungee.listener

import net.azisaba.spicyAzisaBan.SABMessages
import net.md_5.bungee.api.chat.TextComponent
import net.md_5.bungee.api.event.PreLoginEvent
import net.md_5.bungee.api.plugin.Listener
Expand All @@ -9,6 +10,11 @@ object LockdownListener : Listener {
@EventHandler
fun onLogin(e: PreLoginEvent) {
e.isCancelled = true
e.setCancelReason(*TextComponent.fromLegacyText("現在サーバーには参加できません。サーバー管理者へお問い合わせください。 &8(SAB: Initialization error)"))
try {
e.setCancelReason(*TextComponent.fromLegacyText("${SABMessages.General.failsafeKickMessage} (SAB: Initialization error)"))
} catch (ex: Exception) {
ex.printStackTrace()
e.setCancelReason(*TextComponent.fromLegacyText("You cannot join the server right now. Please contact the server administrator. (SAB: Initialization error)"))
}
}
}
29 changes: 29 additions & 0 deletions common/src/main/kotlin/net/azisaba/spicyAzisaBan/SABMessages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ object SABMessages {
val previousPage get() = obj.getMessage("previousPage", defObj.getMessage("previousPage"))
val nextPage get() = obj.getMessage("nextPage", defObj.getMessage("nextPage"))
val datetime get() = obj.getMessage("datetime", defObj.getMessage("datetime"))
val failsafeKickMessage get() = obj.getMessage("failsafeKickMessage", defObj.getMessage("failsafeKickMessage"))

object Time {
private val defObj get() = General.defObj.getObj("time")
Expand All @@ -107,6 +108,34 @@ object SABMessages {
val minute get() = obj.getMessage("minute", defObj.getMessage("minute"))
val second get() = obj.getMessage("second", defObj.getMessage("second"))
}

object Webhook {
private val defObj get() = General.defObj.getObj("webhook")
private val obj get() = General.obj.getObj("webhook")
val type get() = obj.getMessage("type", defObj.getMessage("type"))
val operator get() = obj.getMessage("operator", defObj.getMessage("operator"))
val punishOperator get() = obj.getMessage("punishOperator", defObj.getMessage("punishOperator"))
val target get() = obj.getMessage("target", defObj.getMessage("target"))
val server get() = obj.getMessage("server", defObj.getMessage("server"))
val newReason get() = obj.getMessage("newReason", defObj.getMessage("newReason"))
val oldReason get() = obj.getMessage("oldReason", defObj.getMessage("oldReason"))
val unpunishReason get() = obj.getMessage("unpunishReason", defObj.getMessage("unpunishReason"))
val punishReason get() = obj.getMessage("punishReason", defObj.getMessage("punishReason"))
val punishmentDateTime get() = obj.getMessage("punishmentDateTime", defObj.getMessage("punishmentDateTime"))
val punishmentId get() = obj.getMessage("punishmentId", defObj.getMessage("punishmentId"))
val unpunishId get() = obj.getMessage("unpunishId", defObj.getMessage("unpunishId"))
val proofId get() = obj.getMessage("proofId", defObj.getMessage("proofId"))
val proofText get() = obj.getMessage("proofText", defObj.getMessage("proofText"))
val duration get() = obj.getMessage("duration", defObj.getMessage("duration"))
val expiration get() = obj.getMessage("expiration", defObj.getMessage("expiration"))
val viewableByTarget get() = obj.getMessage("viewableByTarget", defObj.getMessage("viewableByTarget"))
val punishmentAdded get() = obj.getMessage("punishmentAdded", defObj.getMessage("punishmentAdded"))
val punishmentReasonChanged get() = obj.getMessage("punishmentReasonChanged", defObj.getMessage("punishmentReasonChanged"))
val punishmentRemoved get() = obj.getMessage("punishmentRemoved", defObj.getMessage("punishmentRemoved"))
val proofAdded get() = obj.getMessage("proofAdded", defObj.getMessage("proofAdded"))
val proofUpdated get() = obj.getMessage("proofUpdated", defObj.getMessage("proofUpdated"))
val proofRemoved get() = obj.getMessage("proofRemoved", defObj.getMessage("proofRemoved"))
}
}

object Commands {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object AddProofCommand: Command() {
if (e.message == "cancel") return
throw e
}
Proof(proofId, p, text, public).sendWebhook(actor, "証拠が追加されました。", Color.GREEN)
Proof(proofId, p, text, public).sendWebhook(actor, SABMessages.General.Webhook.proofAdded, Color.GREEN)
actor.send(
SABMessages.Commands.AddProof.done
.replaceVariables(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object DelProofCommand: Command() {
val list = SpicyAzisaBan.instance.connection.proofs.delete(FindOptions.Builder().addWhere("id", id).setLimit(1).build()).complete()
if (list.isEmpty()) return actor.send(SABMessages.Commands.General.proofNotFound.replaceVariables().format(id).translate())
val proof = Proof.fromTableData(list[0]).complete()!!
proof.sendWebhook(actor, "証拠が削除されました。", Color.RED)
proof.sendWebhook(actor, SABMessages.General.Webhook.proofRemoved, Color.RED)
actor.send(
SABMessages.Commands.DelProof.done
.replaceVariables("id" to proof.id.toString(), "pid" to proof.punishment.id.toString(), "text" to proof.text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ object NameHistoryCommand : Command() {
"${if (isLast) "<green>" else "<aqua>"}<underlined>$s<reset>"
} else {
if (isLast) {
"<green>$s"
"<green>$s</green>"
} else {
"<yellow>$s"
"<yellow>$s</yellow>"
}
}
}.joinToString("<gray> -> ").let { actor.send(it) }
}.joinToString("<gray> -> </gray>").translate().let { actor.send(it) }
}
}
.catch { actor.sendErrorMessage(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object SABCommand: Command() {
private val groupRemoveConfirmation = mutableMapOf<UUID, String>()

private fun Actor.sendHelp() {
send("$PREFIX<green>SpicyAzisaBan commands".translate())
send("${SABMessages.General.prefix}<green>SpicyAzisaBan commands".translate())
if (hasPermission("sab.command.spicyazisaban.group")) send("${ChatColor.RED}> ${ChatColor.AQUA}/sab group <group>")
if (hasPermission("sab.command.spicyazisaban.info")) send("${ChatColor.RED}> ${ChatColor.AQUA}/sab info")
if (hasPermission("sab.command.spicyazisaban.creategroup")) send("${ChatColor.RED}> ${ChatColor.AQUA}/sab creategroup <group>")
Expand Down Expand Up @@ -131,7 +131,7 @@ object SABCommand: Command() {
.addValue("server", server)
.build()
).complete()
actor.send("$PREFIX${ChatColor.GREEN}グループにサーバー($server)を追加しました。")
actor.send("$PREFIX${ChatColor.GREEN}Added server ($server) to group ($groupName).")
}
"remove" -> {
val server = args[3]
Expand All @@ -141,12 +141,12 @@ object SABCommand: Command() {
.addWhere("server", server)
.build()
).complete()
actor.send("$PREFIX${ChatColor.GREEN}グループからサーバーを(そのグループに入っている場合は)除外しました。")
actor.send("$PREFIX${ChatColor.GREEN}Removed server ($server) from group ($groupName).")
}
"info" -> {
val servers = SpicyAzisaBan.instance.connection.getServersByGroup(args[1]).complete()
actor.send("$PREFIX${ChatColor.AQUA}グループ: ${ChatColor.RESET}$groupName")
actor.send("$PREFIX- ${ChatColor.AQUA}サーバー:")
actor.send("$PREFIX${ChatColor.AQUA}Group: ${ChatColor.RESET}$groupName")
actor.send("$PREFIX- ${ChatColor.AQUA}Servers:")
servers.forEach { server ->
actor.send("$PREFIX - ${ChatColor.GREEN}$server")
}
Expand Down Expand Up @@ -215,7 +215,7 @@ object SABCommand: Command() {
}
"link" -> {
if (actor !is PlayerActor) {
return actor.send("${ChatColor.RED}NO ${ChatColor.AQUA}CONSOLE ${ChatColor.GOLD}ZONE")
return
}
if (args.size <= 1) return
SpicyAzisaBan.instance.connection
Expand Down Expand Up @@ -278,11 +278,11 @@ object SABCommand: Command() {
(SpicyAzisaBan.instance.getPlatformType() != PlatformType.CLI && groupRemoveConfirmation[actor.uniqueId] != groupName)
) {
println("send")
actor.send("$PREFIX${ChatColor.GOLD}グループ「${ChatColor.YELLOW}$groupName${ChatColor.GOLD}」を削除しますか?関連付けられているすべての処罰が解除されます。")
actor.send("$PREFIX${ChatColor.GOLD}Are you sure want to remove group ${ChatColor.YELLOW}$groupName${ChatColor.GOLD}? All punishments associated with this group will be removed and this action cannot be undone.")
if (SpicyAzisaBan.instance.getPlatformType() == PlatformType.CLI) {
actor.send("$PREFIX${ChatColor.GOLD}削除するには${ChatColor.YELLOW}--confirm${ChatColor.GOLD}を入れて実行してください。")
actor.send("$PREFIX${ChatColor.GOLD}If you are sure, re-type the command with ${ChatColor.YELLOW}--confirm${ChatColor.GOLD}.")
} else {
actor.send("$PREFIX${ChatColor.GOLD}削除するには10秒以内に同じコマンドをもう一度実行してください。")
actor.send("$PREFIX${ChatColor.GOLD}If you are sure, re-enter the command within 10 seconds.")
}
if (SpicyAzisaBan.instance.getPlatformType() != PlatformType.CLI) {
groupRemoveConfirmation[actor.uniqueId] = groupName
Expand All @@ -299,7 +299,7 @@ object SABCommand: Command() {
.thenDo { SpicyAzisaBan.instance.connection.serverGroup.delete(FindOptions.Builder().addWhere("group", groupName).build()).complete() }
.thenDo {
SpicyAzisaBan.instance.connection.cachedGroups.set(null)
actor.send("$PREFIX${ChatColor.GREEN}グループに関連付けられた処罰を削除中...")
actor.send("$PREFIX${ChatColor.GREEN}Removing all punishments associated with group ${ChatColor.YELLOW}$groupName${ChatColor.GREEN}...")
SpicyAzisaBan.instance.connection.punishments
.delete(FindOptions.Builder().addWhere("server", groupName).build())
.then { it.map { td -> Punishment.fromTableData(td) } }
Expand All @@ -321,11 +321,11 @@ object SABCommand: Command() {
.catch { actor.sendErrorMessage(it) }
.complete()
groupRemoveConfirmation.remove(actor.uniqueId)
actor.send("$PREFIX${ChatColor.GREEN}グループ「${ChatColor.GOLD}$groupName${ChatColor.GREEN}」を削除しました。")
actor.send("$PREFIX${ChatColor.GREEN}Group ${ChatColor.GOLD}$groupName${ChatColor.GREEN} has been removed.")
}
.catch {
if (it::class.java == Exception::class.java) return@catch
actor.send("$PREFIX${ChatColor.RED}グループの削除に失敗しました。")
actor.send("$PREFIX${ChatColor.RED}Failed to delete group $groupName.")
SpicyAzisaBan.LOGGER.warning("Failed to delete group $groupName")
it.printStackTrace()
}
Expand All @@ -339,7 +339,7 @@ object SABCommand: Command() {
return SpicyAzisaBan.instance.connection.getAllGroups()
.then { list ->
if (list.any { it.equals(groupName, true) }) {
actor.send("$PREFIX${ChatColor.RED}この名前はすでに使用されています。")
actor.send("$PREFIX${ChatColor.RED}Group ${ChatColor.GOLD}$groupName${ChatColor.RED} already exists.")
throw Exception()
}
}
Expand All @@ -351,10 +351,10 @@ object SABCommand: Command() {
}
}
.thenDo { SpicyAzisaBan.instance.connection.cachedGroups.set(null) }
.then { actor.send("${ChatColor.GREEN}グループ「${ChatColor.GOLD}$groupName${ChatColor.GREEN}」を作成しました。") }
.then { actor.send("${ChatColor.GREEN}Group ${ChatColor.GOLD}$groupName${ChatColor.GREEN} has been created.") }
.catch {
if (it::class.java == Exception::class.java) return@catch
actor.send("$PREFIX${ChatColor.RED}グループの作成に失敗しました。")
actor.send("$PREFIX${ChatColor.RED}Failed to create group $groupName.")
it.printStackTrace()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object UpdateProofCommand: Command() {
if (public != null) builder.addValue("public", public)
SpicyAzisaBan.instance.connection.proofs.update(builder.build()).complete()
Proof(proof.id, proof.punishment, text ?: proof.text, public ?: proof.public)
.sendWebhook(actor, "証拠が更新されました。", Color.YELLOW)
.sendWebhook(actor, SABMessages.General.Webhook.proofUpdated, Color.YELLOW)
actor.send(
SABMessages.Commands.UpdateProof.done
.replaceVariables(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object WarnsCommand: Command() {
override val permission = "sab.warns" // this should be set to true for everyone

override fun execute(actor: Actor, args: Array<String>) {
if (actor !is PlayerActor) return actor.send("e^1")
if (actor !is PlayerActor) return
if (!actor.hasPermission(permission)) {
return actor.send(SABMessages.General.missingPermissions.replaceVariables().translate())
}
Expand Down
5 changes: 2 additions & 3 deletions common/src/main/kotlin/net/azisaba/spicyAzisaBan/util/Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,12 @@ object Util {

fun String.translate(): net.kyori.adventure.text.Component {
val legacySectionString = ChatColor.translateAlternateColorCodes('&', this)
.replace(" ", "<white> </white><white> </white>")
try {
// try to parse as mini message
return MiniMessage.miniMessage().deserialize(legacySectionString)
return MiniMessage.miniMessage().deserialize(legacySectionString.replace(" ", "<white> </white><white> </white>"))
} catch (_: Exception) {
// fallback to legacy component
val component = LegacyComponentSerializer.legacySection().deserialize(legacySectionString)
val component = LegacyComponentSerializer.legacySection().deserialize(legacySectionString.replace(" ", "§f §f "))
val miniMessageString = MiniMessage.miniMessage().serialize(component)
return MiniMessage.miniMessage().deserialize(miniMessageString)
}
Expand Down
Loading

0 comments on commit 0a35255

Please sign in to comment.