Skip to content

Commit

Permalink
Implement translations
Browse files Browse the repository at this point in the history
  • Loading branch information
SmylerMC committed Jul 16, 2024
1 parent 5c6701a commit 2601d8a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ 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;

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
Expand Down Expand Up @@ -95,7 +97,7 @@ public SoundSystem soundSystem() {

@Override
public Translator translator() {
return null; //TODO
return this.translator;
}

@Override
Expand Down

0 comments on commit 2601d8a

Please sign in to comment.