From b283480edfefe175d9f7e12a3cd8411e14815b56 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 23 Feb 2021 22:39:51 -0500 Subject: [PATCH] Localize more things --- .../phycon/network/block/terminal/TerminalScreen.kt | 4 ++-- .../phycon/screen/ActivatableDeviceConsoleScreen.kt | 9 --------- .../phycon/screen/RedstoneControllerConsoleScreen.kt | 12 ------------ .../net/shadowfacts/phycon/util/ActivationMode.kt | 8 +++++++- .../net/shadowfacts/phycon/util/RedstoneMode.kt | 6 ++++++ src/main/resources/assets/phycon/lang/en_us.json | 11 ++++++++++- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/main/kotlin/net/shadowfacts/phycon/network/block/terminal/TerminalScreen.kt b/src/main/kotlin/net/shadowfacts/phycon/network/block/terminal/TerminalScreen.kt index 376e194..762c0e9 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/network/block/terminal/TerminalScreen.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/network/block/terminal/TerminalScreen.kt @@ -15,6 +15,7 @@ import net.minecraft.screen.slot.Slot import net.minecraft.screen.slot.SlotActionType import net.minecraft.text.LiteralText import net.minecraft.text.Text +import net.minecraft.text.TranslatableText import net.minecraft.util.Identifier import net.shadowfacts.phycon.PhysicalConnectivity import net.shadowfacts.phycon.networking.C2STerminalRequestItem @@ -161,8 +162,7 @@ class TerminalScreen(handler: TerminalScreenHandler, playerInv: PlayerInventory, override fun drawForeground(matrixStack: MatrixStack, mouseX: Int, mouseY: Int) { textRenderer.draw(matrixStack, title, 65f, 6f, 0x404040) textRenderer.draw(matrixStack, playerInventory.displayName, 65f, backgroundHeight - 94f, 0x404040) - // todo: translate this - textRenderer.draw(matrixStack, "Buffer", 7f, 6f, 0x404040) + textRenderer.draw(matrixStack, TranslatableText("gui.phycon.terminal_buffer"), 7f, 6f, 0x404040) } override fun drawBackground(matrixStack: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) { diff --git a/src/main/kotlin/net/shadowfacts/phycon/screen/ActivatableDeviceConsoleScreen.kt b/src/main/kotlin/net/shadowfacts/phycon/screen/ActivatableDeviceConsoleScreen.kt index 609dc5e..dedec57 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/screen/ActivatableDeviceConsoleScreen.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/screen/ActivatableDeviceConsoleScreen.kt @@ -4,12 +4,9 @@ import com.mojang.blaze3d.systems.RenderSystem import net.minecraft.client.gui.screen.Screen import net.minecraft.client.gui.widget.ButtonWidget import net.minecraft.client.util.math.MatrixStack -import net.minecraft.text.LiteralText -import net.minecraft.text.Text import net.shadowfacts.phycon.network.DeviceBlockEntity import net.shadowfacts.phycon.network.component.ActivationController import net.shadowfacts.phycon.networking.C2SConfigureActivationMode -import net.shadowfacts.phycon.util.ActivationMode import net.shadowfacts.phycon.util.next import org.lwjgl.glfw.GLFW @@ -66,10 +63,4 @@ class ActivatableDeviceConsoleScreen( textRenderer.draw(matrixStack, "MAC Address: ${device.macAddress}", minX + 5f, minY + 15f, 0x404040) } - private val ActivationMode.friendlyName: Text - get() = when (this) { - ActivationMode.AUTOMATIC -> LiteralText("Automatic") - ActivationMode.MANAGED -> LiteralText("Managed") - } - } diff --git a/src/main/kotlin/net/shadowfacts/phycon/screen/RedstoneControllerConsoleScreen.kt b/src/main/kotlin/net/shadowfacts/phycon/screen/RedstoneControllerConsoleScreen.kt index b327a80..1a6bea6 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/screen/RedstoneControllerConsoleScreen.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/screen/RedstoneControllerConsoleScreen.kt @@ -1,17 +1,14 @@ package net.shadowfacts.phycon.screen import com.mojang.blaze3d.systems.RenderSystem -import net.minecraft.client.font.TextRenderer import net.minecraft.client.gui.screen.Screen import net.minecraft.client.gui.widget.ButtonWidget import net.minecraft.client.gui.widget.TextFieldWidget import net.minecraft.client.util.math.MatrixStack import net.minecraft.text.LiteralText -import net.minecraft.text.Text import net.shadowfacts.phycon.api.util.IPAddress import net.shadowfacts.phycon.network.block.redstone.RedstoneControllerBlockEntity import net.shadowfacts.phycon.networking.C2SConfigureRedstoneController -import net.shadowfacts.phycon.util.RedstoneMode import net.shadowfacts.phycon.util.next import org.lwjgl.glfw.GLFW @@ -99,13 +96,4 @@ class RedstoneControllerConsoleScreen( textRenderer.draw(matrixStack, "MAC Address: ${device.macAddress}", minX + 5f, minY + 15f, 0x404040) } - private val RedstoneMode.friendlyName: Text - get() = LiteralText(when (this) { - RedstoneMode.HIGH -> "High" - RedstoneMode.LOW -> "Low" - RedstoneMode.TOGGLE -> "Toggle" - RedstoneMode.RISING_EDGE -> "Rising Edge" - RedstoneMode.FALLING_EDGE -> "Falling Edge" - }) - } diff --git a/src/main/kotlin/net/shadowfacts/phycon/util/ActivationMode.kt b/src/main/kotlin/net/shadowfacts/phycon/util/ActivationMode.kt index 28fa901..3ab9b3d 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/util/ActivationMode.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/util/ActivationMode.kt @@ -1,9 +1,15 @@ package net.shadowfacts.phycon.util +import net.minecraft.text.Text +import net.minecraft.text.TranslatableText + /** * @author shadowfacts */ enum class ActivationMode: RotatableEnum { AUTOMATIC, - MANAGED, + MANAGED; + + val friendlyName: Text + get() = TranslatableText("gui.phycon.activation_mode.${name.toLowerCase()}") } diff --git a/src/main/kotlin/net/shadowfacts/phycon/util/RedstoneMode.kt b/src/main/kotlin/net/shadowfacts/phycon/util/RedstoneMode.kt index cf2c7f3..a7882bf 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/util/RedstoneMode.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/util/RedstoneMode.kt @@ -1,5 +1,8 @@ package net.shadowfacts.phycon.util +import net.minecraft.text.Text +import net.minecraft.text.TranslatableText + /** * @author shadowfacts */ @@ -21,4 +24,7 @@ enum class RedstoneMode: RotatableEnum { HIGH, LOW -> true else -> false } + + val friendlyName: Text + get() = TranslatableText("gui.phycon.redstone_mode.${name.toLowerCase()}") } diff --git a/src/main/resources/assets/phycon/lang/en_us.json b/src/main/resources/assets/phycon/lang/en_us.json index d88e438..ea4ce28 100644 --- a/src/main/resources/assets/phycon/lang/en_us.json +++ b/src/main/resources/assets/phycon/lang/en_us.json @@ -8,5 +8,14 @@ "block.phycon.redstone_controller": "Redstone Controller", "item.phycon.screwdriver": "Screwdriver", - "item.phycon.console": "Console" + "item.phycon.console": "Console", + + "gui.phycon.terminal_buffer": "Buffer", + "gui.phycon.redstone_mode.high": "High", + "gui.phycon.redstone_mode.low": "Low", + "gui.phycon.redstone_mode.toggle": "Toggle", + "gui.phycon.redstone_mode.rising_edge": "Rising Edge", + "gui.phycon.redstone_mode.falling_edge": "Falling Edge", + "gui.phycon.activation_mode.automatic": "Automatic", + "gui.phycon.activation_mode.managed": "Managed" }