From fb82e9d792fca60c65d5d4df59e117825e75ecba Mon Sep 17 00:00:00 2001 From: Cassian Godsted Date: Mon, 30 Dec 2024 08:01:15 -0500 Subject: [PATCH] Fix overriding vanilla translations (#4187) (#4335) (cherry picked from commit e82f21f7e92545027a4dec8081c1bcac860a8259) Co-authored-by: apple502j <33279053+apple502j@users.noreply.github.com> --- .../resource/loader/server/LanguageMixin.java | 14 ++++++++++++++ .../test/resource/loader/LanguageTestMod.java | 2 ++ .../resources/assets/minecraft/lang/en_us.json | 3 +++ 3 files changed, 19 insertions(+) create mode 100644 fabric-resource-loader-v0/src/testmod/resources/assets/minecraft/lang/en_us.json diff --git a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/server/LanguageMixin.java b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/server/LanguageMixin.java index c7c6d2cd2b..1ec0d82cf0 100644 --- a/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/server/LanguageMixin.java +++ b/fabric-resource-loader-v0/src/main/java/net/fabricmc/fabric/mixin/resource/loader/server/LanguageMixin.java @@ -36,6 +36,8 @@ import net.minecraft.util.Language; import net.fabricmc.fabric.impl.resource.loader.ServerLanguageUtil; +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; @Mixin(Language.class) class LanguageMixin { @@ -54,6 +56,18 @@ private static ImmutableMap create(ImmutableMap.Builder entryConsumer) { try (InputStream stream = Files.newInputStream(path)) { LOGGER.debug("Loading translations from {}", path); diff --git a/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/LanguageTestMod.java b/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/LanguageTestMod.java index ff59f36ad9..7b75a5e158 100644 --- a/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/LanguageTestMod.java +++ b/fabric-resource-loader-v0/src/testmod/java/net/fabricmc/fabric/test/resource/loader/LanguageTestMod.java @@ -27,6 +27,8 @@ public void onInitializeServer() { } private static void testTranslationLoaded() { + testTranslationLoaded("item.minecraft.potato", "Potato"); // Test that vanilla translation loads + testTranslationLoaded("text.fabric-resource-loader-v0-testmod.server.lang.override", "Vanilla override test"); testTranslationLoaded("pack.source.fabricmod", "Fabric mod"); testTranslationLoaded("text.fabric-resource-loader-v0-testmod.server.lang.test0", "Test from fabric-resource-loader-v0-testmod"); testTranslationLoaded("text.fabric-resource-loader-v0-testmod.server.lang.test1", "Test from fabric-resource-loader-v0-testmod-test1"); diff --git a/fabric-resource-loader-v0/src/testmod/resources/assets/minecraft/lang/en_us.json b/fabric-resource-loader-v0/src/testmod/resources/assets/minecraft/lang/en_us.json new file mode 100644 index 0000000000..3943934aa1 --- /dev/null +++ b/fabric-resource-loader-v0/src/testmod/resources/assets/minecraft/lang/en_us.json @@ -0,0 +1,3 @@ +{ + "text.fabric-resource-loader-v0-testmod.server.lang.override": "Vanilla override test" +}