Skip to content

Commit

Permalink
Always load en_US lang files from mods into the default language.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSVK12 committed Sep 29, 2023
1 parent 9656ee8 commit b73b88c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

13 changes: 13 additions & 0 deletions src/main/java/turniplabs/halplibe/mixin/mixins/I18nMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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();
}
}
}
}
}
Expand Down

0 comments on commit b73b88c

Please sign in to comment.