diff --git a/smylib/fabric/src/main/java/net/smyler/smylib/game/I18nTranslator.java b/smylib/fabric/src/main/java/net/smyler/smylib/game/I18nTranslator.java new file mode 100644 index 00000000..230fb363 --- /dev/null +++ b/smylib/fabric/src/main/java/net/smyler/smylib/game/I18nTranslator.java @@ -0,0 +1,30 @@ +package net.smyler.smylib.game; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.language.I18n; +import net.minecraft.client.resources.language.LanguageManager; + +public class I18nTranslator implements Translator { + + private final LanguageManager languageManager; + + public I18nTranslator(Minecraft minecraft) { + this.languageManager = minecraft.getLanguageManager(); + } + + @Override + public String language() { + return this.languageManager.getSelected(); + } + + @Override + public boolean hasKey(String key) { + return I18n.exists(key); + } + + @Override + public String format(String key, Object... parameters) { + return I18n.get(key, parameters); + } + +} diff --git a/smylib/fabric/src/main/java/net/smyler/smylib/game/WrappedMinecraft.java b/smylib/fabric/src/main/java/net/smyler/smylib/game/WrappedMinecraft.java index 59306736..840532ea 100644 --- a/smylib/fabric/src/main/java/net/smyler/smylib/game/WrappedMinecraft.java +++ b/smylib/fabric/src/main/java/net/smyler/smylib/game/WrappedMinecraft.java @@ -22,6 +22,7 @@ public class WrappedMinecraft implements GameClient { private WrappedGuiGraphics uiDrawContext; private final WrappedSoundSystem soundSystem = new WrappedSoundSystem(); private final SpriteLibrary spriteLibrary = new VanillaSprites(); + private final Translator translator; private WrappedVanillaScreen lastAccessedVanillaScreen = null; @@ -29,6 +30,7 @@ public WrappedMinecraft(Minecraft client) { this.client = client; this.mouse = new GlfwMouse(this.client); this.keyboard = new GlfwKeyboard(this.client); + this.translator = new I18nTranslator(this.client); } @Override @@ -95,7 +97,7 @@ public SoundSystem soundSystem() { @Override public Translator translator() { - return null; //TODO + return this.translator; } @Override