public static String getString(String messageKey, String defaultVal) { if(selectedLanguage == null) { return defaultVal; } if (!translations.ContainsKey(selectedLanguage)) { translations[selectedLanguage] = new Translation(selectedLanguage); } if(translations[selectedLanguage].getString(messageKey) == null) { translations[selectedLanguage].addString(messageKey, defaultVal); translations[selectedLanguage].save(); } return (translations[selectedLanguage].getString(messageKey) == null ? defaultVal : translations[selectedLanguage].getString(messageKey)); }
public static void init() { foreach(String file in System.IO.Directory.GetFiles("Translations")) { if (file.EndsWith(".json")) { String code = file.Substring(file.LastIndexOf(@"\") + 1); code = code.Substring(0, code.LastIndexOf(".")); if (!translations.ContainsKey(code)) { translations[code] = new Translation(code); } else { throw new Exception("Language already defined"); } } } }