Makes the fallback language configurable

This commit is contained in:
Kristian Knarvik 2023-01-25 16:03:50 +01:00
parent 4f7f33be27
commit 341fce44e5
2 changed files with 9 additions and 2 deletions

View File

@ -84,5 +84,11 @@
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -48,10 +48,11 @@ public final class Translator {
* Loads the languages used by this translator
*
* @param dataFolder <p>The data folder to load custom strings from</p>
* @param fallbackLanguage <p>The default language to fall back on in the case of missing translations</p>
* @param selectedLanguage <p>The currently selected language</p>
*/
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);