From 03f6c9e2f98ec136c34506180cd7170bb39dcae0 Mon Sep 17 00:00:00 2001 From: Blood-Asp Date: Wed, 26 Oct 2016 18:44:14 +0200 Subject: [PATCH] Replace not working localization function with own map. --- .../gregtech/api/util/GT_LanguageManager.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java index 9937d0c0..36b543b1 100644 --- a/src/main/java/gregtech/api/util/GT_LanguageManager.java +++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java @@ -14,8 +14,9 @@ import java.util.Map.Entry; import static gregtech.api.enums.GT_Values.E; public class GT_LanguageManager { - public static final HashMap TEMPMAP = new HashMap(), BUFFERMAP = new HashMap(); + public static final HashMap TEMPMAP = new HashMap(), BUFFERMAP = new HashMap(), LANGMAP = new HashMap(); public static Configuration sEnglishFile; + public static boolean sUseEnglishFile = false; public static String addStringLocalization(String aKey, String aEnglish) { return addStringLocalization(aKey, aEnglish, true); @@ -23,10 +24,17 @@ public class GT_LanguageManager { public static String addStringLocalization(String aKey, String aEnglish, boolean aWriteIntoLangFile) { if (aKey == null) return E; - if (aWriteIntoLangFile) aEnglish = writeToLangFile(aKey, aEnglish); + if (aWriteIntoLangFile){ aEnglish = writeToLangFile(aKey, aEnglish); + if(!LANGMAP.containsKey(aKey)){ + LANGMAP.put(aKey, aEnglish); + } + } TEMPMAP.put(aKey.trim(), aEnglish); LanguageRegistry.instance().injectLanguage("en_US", TEMPMAP); TEMPMAP.clear(); + if(sUseEnglishFile && !aWriteIntoLangFile && LANGMAP.containsKey(aKey)){ + aEnglish = LANGMAP.get(aKey); + } return aEnglish; } @@ -44,8 +52,10 @@ public class GT_LanguageManager { } Property tProperty = sEnglishFile.get("LanguageFile", aKey.trim(), aEnglish); if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) sEnglishFile.save(); - if (sEnglishFile.get("EnableLangFile", "UseThisFileAsLanguageFile", false).getBoolean(false)) + if (sEnglishFile.get("EnableLangFile", "UseThisFileAsLanguageFile", false).getBoolean(false)){ aEnglish = tProperty.getString(); + sUseEnglishFile = true; + } } return aEnglish; }