From 341fce44e50584f29f30e7d7629f9ee221f61372 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Wed, 25 Jan 2023 16:03:50 +0100 Subject: [PATCH] Makes the fallback language configurable --- pom.xml | 6 ++++++ .../java/net/knarcraft/knarlib/formatting/Translator.java | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ae5f6fd..7d09aec 100644 --- a/pom.xml +++ b/pom.xml @@ -84,5 +84,11 @@ 1.19.2-R0.1-SNAPSHOT provided + + org.junit.jupiter + junit-jupiter + 5.9.2 + test + diff --git a/src/main/java/net/knarcraft/knarlib/formatting/Translator.java b/src/main/java/net/knarcraft/knarlib/formatting/Translator.java index b241748..1692c55 100644 --- a/src/main/java/net/knarcraft/knarlib/formatting/Translator.java +++ b/src/main/java/net/knarcraft/knarlib/formatting/Translator.java @@ -48,10 +48,11 @@ public final class Translator { * Loads the languages used by this translator * * @param dataFolder

The data folder to load custom strings from

+ * @param fallbackLanguage

The default language to fall back on in the case of missing translations

* @param selectedLanguage

The currently selected language

*/ - public void loadLanguages(File dataFolder, String selectedLanguage) { - backupTranslatedMessages = loadTranslatedMessages("en"); + public void loadLanguages(File dataFolder, String fallbackLanguage, String selectedLanguage) { + backupTranslatedMessages = loadTranslatedMessages(fallbackLanguage); translatedMessages = loadCustomTranslatedMessages(dataFolder, selectedLanguage); if (translatedMessages == null) { translatedMessages = loadTranslatedMessages(selectedLanguage);