From b73b88cf5e168414156264d3e7680e1053fb6514 Mon Sep 17 00:00:00 2001 From: MartinSVK12 <37455793+MartinSVK12@users.noreply.github.com> Date: Fri, 29 Sep 2023 17:52:31 +0200 Subject: [PATCH] Always load en_US lang files from mods into the default language. --- gradle.properties | 2 +- .../turniplabs/halplibe/mixin/mixins/I18nMixin.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index d3362d5..f3eed1e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ bta_version=1.7.7.0_02 loader_version=0.14.19-babric.1-bta # Mod -mod_version=2.3.0 +mod_version=2.3.1 mod_group=turniplabs mod_name=halplibe diff --git a/src/main/java/turniplabs/halplibe/mixin/mixins/I18nMixin.java b/src/main/java/turniplabs/halplibe/mixin/mixins/I18nMixin.java index 81e943e..30f9bf2 100644 --- a/src/main/java/turniplabs/halplibe/mixin/mixins/I18nMixin.java +++ b/src/main/java/turniplabs/halplibe/mixin/mixins/I18nMixin.java @@ -95,6 +95,9 @@ public static InputStream getResourceAsStream(String path) { ) public void addHalplibeModLangFiles(String languageCode, boolean save, CallbackInfo ci) { Properties entries = ((LanguageAccessor) currentLanguage).getEntries(); + Language defaultLanguage = Language.Default.INSTANCE; + Properties defaultEntries = ((LanguageAccessor) defaultLanguage).getEntries(); //if you see a ClassCastException warning here, it is wrong, nothing happens + String defaultLangId = defaultLanguage.getId(); String currentLangId = currentLanguage.getId(); HalpLibe.LOGGER.debug("Current lang: " + currentLangId); for (ModContainer mod : FabricLoader.getInstance().getAllMods()) { @@ -112,6 +115,16 @@ public void addHalplibeModLangFiles(String languageCode, boolean save, CallbackI e.printStackTrace(); } } + if(lang.contains(defaultLangId)){ + try (InputStream stream = getResourceAsStream(lang)) { + if (stream != null) { + InputStreamReader r = new InputStreamReader(stream, StandardCharsets.UTF_8); + defaultEntries.load(r); + } + } catch (IOException e) { + e.printStackTrace(); + } + } } } }