-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
smylib/fabric/src/main/java/net/smyler/smylib/game/I18nTranslator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters