From d30ef93c29fba34b30f9d123d876d8f6916c604e Mon Sep 17 00:00:00 2001 From: Roman Hubenkov Date: Mon, 6 Apr 2020 04:31:34 +0300 Subject: [PATCH] Update OtherModChanger.java --- .../lang/OtherModChanger.java | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/main/java/ru/glitchless/serverlocalization/lang/OtherModChanger.java b/src/main/java/ru/glitchless/serverlocalization/lang/OtherModChanger.java index 81b055f..a3e340b 100644 --- a/src/main/java/ru/glitchless/serverlocalization/lang/OtherModChanger.java +++ b/src/main/java/ru/glitchless/serverlocalization/lang/OtherModChanger.java @@ -8,15 +8,26 @@ import java.io.InputStream; public class OtherModChanger implements ILangChanger { - @Override - public void changeLanguage(Logger logger, String lang) throws LangNotFoundException { - for (ModContainer container : Loader.instance().getActiveModList()) { - InputStream is = OtherModChanger.class.getResourceAsStream("/assets/" + container.getModId() + "/lang/" + lang + ".lang"); - if (is == null) { - continue; - } - LanguageMap.inject(is); - logger.info("Change lang to " + lang + " for " + container.getModId() + " done!"); - } - } + @Override + public void changeLanguage(Logger logger, String lang) throws LangNotFoundException { + int len = lang.length(); + for (ModContainer container : Loader.instance().getActiveModList()) { + char[][] tmp = new char[2][]; + tmp[0] = lang.toLowerCase().toCharArray(); + tmp[1] = lang.toUpperCase().toCharArray(); + for (int i = 0; i < 1 << len; i++) { + String value = ""; + for (int j = 0; j < len; j++) { + value += tmp[(i >> j) % 2][j]; + } + InputStream is = OtherModChanger.class.getResourceAsStream("/assets/" + container.getModId() + "/lang/" + value + ".lang"); + if (is == null) { + continue; + } + LanguageMap.inject(is); + logger.info("Change lang to " + value + " for " + container.getModId() + " done!"); + break; + } + } + } }