Replace not working localization function with own map.
This commit is contained in:
parent
508c229340
commit
d8aa0e6ebf
1 changed files with 13 additions and 3 deletions
|
@ -14,8 +14,9 @@ import java.util.Map.Entry;
|
||||||
import static gregtech.api.enums.GT_Values.E;
|
import static gregtech.api.enums.GT_Values.E;
|
||||||
|
|
||||||
public class GT_LanguageManager {
|
public class GT_LanguageManager {
|
||||||
public static final HashMap<String, String> TEMPMAP = new HashMap<String, String>(), BUFFERMAP = new HashMap<String, String>();
|
public static final HashMap<String, String> TEMPMAP = new HashMap<String, String>(), BUFFERMAP = new HashMap<String, String>(), LANGMAP = new HashMap<String, String>();
|
||||||
public static Configuration sEnglishFile;
|
public static Configuration sEnglishFile;
|
||||||
|
public static boolean sUseEnglishFile = false;
|
||||||
|
|
||||||
public static String addStringLocalization(String aKey, String aEnglish) {
|
public static String addStringLocalization(String aKey, String aEnglish) {
|
||||||
return addStringLocalization(aKey, aEnglish, true);
|
return addStringLocalization(aKey, aEnglish, true);
|
||||||
|
@ -23,10 +24,17 @@ public class GT_LanguageManager {
|
||||||
|
|
||||||
public static String addStringLocalization(String aKey, String aEnglish, boolean aWriteIntoLangFile) {
|
public static String addStringLocalization(String aKey, String aEnglish, boolean aWriteIntoLangFile) {
|
||||||
if (aKey == null) return E;
|
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);
|
TEMPMAP.put(aKey.trim(), aEnglish);
|
||||||
LanguageRegistry.instance().injectLanguage("en_US", TEMPMAP);
|
LanguageRegistry.instance().injectLanguage("en_US", TEMPMAP);
|
||||||
TEMPMAP.clear();
|
TEMPMAP.clear();
|
||||||
|
if(sUseEnglishFile && !aWriteIntoLangFile && LANGMAP.containsKey(aKey)){
|
||||||
|
aEnglish = LANGMAP.get(aKey);
|
||||||
|
}
|
||||||
return aEnglish;
|
return aEnglish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +52,10 @@ public class GT_LanguageManager {
|
||||||
}
|
}
|
||||||
Property tProperty = sEnglishFile.get("LanguageFile", aKey.trim(), aEnglish);
|
Property tProperty = sEnglishFile.get("LanguageFile", aKey.trim(), aEnglish);
|
||||||
if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) sEnglishFile.save();
|
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();
|
aEnglish = tProperty.getString();
|
||||||
|
sUseEnglishFile = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return aEnglish;
|
return aEnglish;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue