Skip to content

Commit

Permalink
chore: add some i18n keys
Browse files Browse the repository at this point in the history
  • Loading branch information
luluxiaoyu committed Jun 14, 2024
1 parent cf8f401 commit 2fb0d75
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 158 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ yarn_mappings=1.21+build.1
loader_version=0.15.11

# Mod Properties
mod_version = 1.5-mc1.21-SNAPSHOT
mod_version = 1.5.1-mc1.21-SNAPSHOT
maven_group = cn.nstarmc
archives_base_name = ash3

Expand Down
22 changes: 11 additions & 11 deletions src/main/java/cn/nstarmc/ash3/AshCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@

public class AshCommands {

private static final String COMMAND_TOGGLE = "ash2toggle";
private static final String COMMAND_RESET = "ash2reset";
private static final String COMMAND_FPS = "ash2togglefps";
private static final String COMMAND_COORDS = "ash2togglecoords";
private static final String COMMAND_DIRECTION = "ash2toggledirection";
private static final String COMMAND_COLOR = "ash2color";
private static final String COMMAND_BACKGROUND_COLOR = "ash2backgroundcolor";
private static final String COMMAND_LIGHTLEVEL = "ash2togglelightlevel";
private static final String COMMAND_TIME = "ash2toggletime";
private static final String COMMAND_CONCISE_COORDS = "ash2toggleconcisecoords";
private static final String COMMAND_TOGGLE_BACKGROUND = "ash2togglebackground";
private static final String COMMAND_TOGGLE = "ash3toggle";
private static final String COMMAND_RESET = "ash3reset";
private static final String COMMAND_FPS = "ash3togglefps";
private static final String COMMAND_COORDS = "ash3togglecoords";
private static final String COMMAND_DIRECTION = "ash3toggledirection";
private static final String COMMAND_COLOR = "ash3color";
private static final String COMMAND_BACKGROUND_COLOR = "ash3backgroundcolor";
private static final String COMMAND_LIGHTLEVEL = "ash3togglelightlevel";
private static final String COMMAND_TIME = "ash3toggletime";
private static final String COMMAND_CONCISE_COORDS = "ash3toggleconcisecoords";
private static final String COMMAND_TOGGLE_BACKGROUND = "ash3togglebackground";

public static AshConfig config;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/nstarmc/ash3/AshMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

public class AshMod implements ClientModInitializer {

public static final String MOD_ID = "ash2";
public static final String MOD_ID = "ash3";
public static ConfigManager<AshConfig> configManager;

@Override
public void onInitializeClient() {
configManager = (ConfigManager<AshConfig>) AutoConfig.register(AshConfig.class, GsonConfigSerializer::new);

KeyBinding toggleAsh = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.ash2.toggleAsh", InputUtil.Type.KEYSYM, InputUtil.UNKNOWN_KEY.getCode(), "key.categories.misc"));
KeyBinding toggleAsh = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.ash3.toggleAsh", InputUtil.Type.KEYSYM, InputUtil.UNKNOWN_KEY.getCode(), "key.categories.misc"));

ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (toggleAsh.wasPressed()) {
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/cn/nstarmc/ash3/DirectionEnum.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package cn.nstarmc.ash3;

import net.minecraft.client.resource.language.I18n;

public enum DirectionEnum {

N("North"), NE("North-east"), E("East"), SE("South-east"), S("South"), SW("South-west"), W("West"),
NW("North-west");
N(I18n.translate("direction.north")),
NE(I18n.translate("direction.northeast")),
E(I18n.translate("direction.east")),
SE(I18n.translate("direction.southeast")),
S(I18n.translate("direction.south")),
SW(I18n.translate("direction.southwest")),
W(I18n.translate("direction.west")),
NW(I18n.translate("direction.northwest"));


public String longName;

Expand Down
11 changes: 6 additions & 5 deletions src/main/java/cn/nstarmc/ash3/mixin/InGameHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cn.nstarmc.ash3.AshCommands;
import cn.nstarmc.ash3.DirectionEnum;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.client.resource.language.I18n;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand Down Expand Up @@ -117,7 +118,7 @@ private void drawCoordsAndDirection(DrawContext drawContext, MinecraftClient cli
if (!AshCommands.config.showDirection || AshCommands.config.conciseCoords)
return;

String ashString = "Direction: " + directionEnum.longName;
String ashString = I18n.translate("text.ash3.ui.direction") + directionEnum.longName;

drawContext.drawTextWithShadow(client.textRenderer, ashString, TEXT_POS_X, textPosY, AshCommands.config.hudColor);
if (AshCommands.config.showBackground)
Expand All @@ -133,7 +134,7 @@ private void drawLightLevel(DrawContext drawContext, MinecraftClient client, Ent

BlockPos blockPos = cameraEntity.getBlockPos();
int lightLevel = client.world.getLightLevel(LightType.BLOCK, blockPos);
String ashString = "Light Level: " + lightLevel;
String ashString = I18n.translate("text.ash3.ui.lightlevel") + lightLevel;

int color = AshCommands.config.hudColor;
if (lightLevel == 0) {
Expand All @@ -154,7 +155,7 @@ private void drawBiome(DrawContext drawContext, MinecraftClient client, Entity c

BlockPos blockPos = cameraEntity.getBlockPos();
String biomeKey = client.world.getBiome(blockPos).getKey().get().getValue().toTranslationKey("biome");
String ashString = "Biome: " + Text.translatable(biomeKey).getString();
String ashString = I18n.translate("text.ash3.ui.biome") + Text.translatable(biomeKey).getString();

drawContext.drawTextWithShadow(client.textRenderer, ashString, TEXT_POS_X, textPosY, AshCommands.config.hudColor);
if (AshCommands.config.showBackground)
Expand All @@ -173,9 +174,9 @@ private void drawTime(DrawContext drawContext, MinecraftClient client, Entity ca
int minutes = (int) ((client.world.getTimeOfDay() / 1000d * 60) % 60);
String ashString;
if (minutes <= 9) {
ashString = String.format("Time: %d:0%d", hour, minutes);
ashString = String.format(I18n.translate("text.ash3.ui.time") + "%d:0%d", hour, minutes);
} else {
ashString = String.format("Time: %d:%d", hour, minutes);
ashString = String.format(I18n.translate("text.ash3.ui.time") + "%d:%d", hour, minutes);
}

drawContext.drawTextWithShadow(client.textRenderer, ashString, TEXT_POS_X, textPosY, AshCommands.config.hudColor);
Expand Down
110 changes: 0 additions & 110 deletions src/main/java/com/umollu/ash/AshCommands.java

This file was deleted.

38 changes: 25 additions & 13 deletions src/main/resources/assets/ash3/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
{
"text.autoconfig.ash2.title" : "ASH Config",
"text.autoconfig.ash2.option.showHud" : "Show HUD",
"text.autoconfig.ash2.option.hudColor" : "HUD text color",
"text.autoconfig.ash2.option.hudBackgroundColor" : "HUD background value",
"text.autoconfig.ash2.option.showFps" : "Show FPS",
"text.autoconfig.ash2.option.showCoords" : "Show coordinates",
"text.autoconfig.ash2.option.showDirection" : "Show direction",
"text.autoconfig.ash2.option.showLightLevel" : "Show light level",
"text.autoconfig.ash2.option.showBiome" : "Show biome",
"text.autoconfig.ash2.option.showTime" : "Show time",
"text.autoconfig.ash2.option.conciseCoords" : "Concise coords",
"text.autoconfig.ash2.option.showBackground" : "Show HUD background",
"key.ash2.toggleAsh" : "Toggle ASH HUD"
"text.autoconfig.ash3.title" : "ASH Config",
"text.autoconfig.ash3.option.showHud" : "Show HUD",
"text.autoconfig.ash3.option.hudColor" : "HUD text color",
"text.autoconfig.ash3.option.hudBackgroundColor" : "HUD background value",
"text.autoconfig.ash3.option.showFps" : "Show FPS",
"text.autoconfig.ash3.option.showCoords" : "Show coordinates",
"text.autoconfig.ash3.option.showDirection" : "Show direction",
"text.autoconfig.ash3.option.showLightLevel" : "Show light level",
"text.autoconfig.ash3.option.showBiome" : "Show biome",
"text.autoconfig.ash3.option.showTime" : "Show time",
"text.autoconfig.ash3.option.conciseCoords" : "Concise coords",
"text.autoconfig.ash3.option.showBackground" : "Show HUD background",
"key.ash3.toggleAsh" : "Toggle ASH HUD",
"direction.north": "North",
"direction.northeast": "North-East",
"direction.east": "East",
"direction.southeast": "South-East",
"direction.south": "South",
"direction.southwest": "South-West",
"direction.west": "West",
"direction.northwest": "North-West",
"text.ash3.ui.direction": "Direction: ",
"text.ash3.ui.lightlevel": "Light Level: ",
"text.ash3.ui.biome": "Biome: ",
"text.ash3.ui.time": "Time: "
}
38 changes: 25 additions & 13 deletions src/main/resources/assets/ash3/lang/zh_cn.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
{
"text.autoconfig.ash2.title" : "ASH3配置",
"text.autoconfig.ash2.option.showHud" : "显示游戏HUD",
"text.autoconfig.ash2.option.hudColor" : "HUD文字颜色",
"text.autoconfig.ash2.option.hudBackgroundColor" : "HUD背景颜色",
"text.autoconfig.ash2.option.showFps" : "显示FPS",
"text.autoconfig.ash2.option.showCoords" : "显示坐标",
"text.autoconfig.ash2.option.showDirection" : "显示反向",
"text.autoconfig.ash2.option.showLightLevel" : "显示光照等级",
"text.autoconfig.ash2.option.showBiome" : "显示生物群系",
"text.autoconfig.ash2.option.showTime" : "显示时间",
"text.autoconfig.ash2.option.conciseCoords" : "简单坐标",
"text.autoconfig.ash2.option.showBackground" : "显示HUD背景色",
"key.ash2.toggleAsh" : "切换 ASH HUD 是否显示"
"text.autoconfig.ash3.title" : "ASH3配置",
"text.autoconfig.ash3.option.showHud" : "显示游戏HUD",
"text.autoconfig.ash3.option.hudColor" : "HUD文字颜色",
"text.autoconfig.ash3.option.hudBackgroundColor" : "HUD背景颜色",
"text.autoconfig.ash3.option.showFps" : "显示FPS",
"text.autoconfig.ash3.option.showCoords" : "显示坐标",
"text.autoconfig.ash3.option.showDirection" : "显示反向",
"text.autoconfig.ash3.option.showLightLevel" : "显示光照等级",
"text.autoconfig.ash3.option.showBiome" : "显示生物群系",
"text.autoconfig.ash3.option.showTime" : "显示时间",
"text.autoconfig.ash3.option.conciseCoords" : "简单坐标",
"text.autoconfig.ash3.option.showBackground" : "显示HUD背景色",
"key.ash3.toggleAsh" : "切换 ASH HUD 是否显示",
"direction.north": "",
"direction.northeast": "东北",
"direction.east": "",
"direction.southeast": "东南",
"direction.south": "",
"direction.southwest": "西南",
"direction.west": "西",
"direction.northwest": "西北",
"text.ash3.ui.direction": "方向: ",
"text.ash3.ui.lightlevel": "光照等级: ",
"text.ash3.ui.biome": "生物群系: ",
"text.ash3.ui.time": "时间: "
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"ash3.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.22",
"fabricloader": ">=0.15",
"fabric": "*",
"minecraft": ">=1.21",
"java": ">=21",
Expand Down

0 comments on commit 2fb0d75

Please sign in to comment.