static LEStringTableEditor() { #if UNITY_EDITOR_OSX const int RTLD_NOW = 2; lebidiLibHandle = dlopen(Path.Combine(LESettings.FullRootDir, LEConstants.LEBidiOSXPath), RTLD_NOW); if (lebidiLibHandle == IntPtr.Zero) { throw new Exception(LEConstants.BidiSupportDllError); } getbidiHandle = dlsym(lebidiLibHandle, LEConstants.GetBidiHandle); if (getbidiHandle == IntPtr.Zero) { throw new Exception(LEConstants.BidiSupportGetFunctionHandleError); } #endif // Load after scripts have been reloaded Load(); if (!string.IsNullOrEmpty(LESettings.Instance.LastSelectedLocSet) && AllLangsVisual.ContainsKey(LESettings.Instance.LastSelectedLocSet)) { CurrentLanguage = LESettings.Instance.LastSelectedLocSet; } else if (AllLangsVisual.Count > 0) { CurrentLanguage = AllLangsVisual.Keys.ToArray()[0]; } }
public static void RemoveLanguage(string name) { string path = Path.Combine(LESettings.VisualLocFilePath, name + LEConstants.VisualFileExtension); string logicalPath = Path.Combine(LESettings.LogicalLocFilePath, name + LEConstants.LogicalFileExtension); // Delete the language file File.Delete(path); File.Delete(logicalPath); // Remove the language from the collection AllLangsVisual.Remove(name); AllLangsLogical.Remove(name); // If the deleted language is currently selected, unset it if (CurrentLanguage.Equals(name)) { CurrentLanguage = string.Empty; } if (AllLangsLogical.Count == 0) { MasterKeys.Clear(); } NeedsSave = true; }
public static void ClearAll() { AllLangsLogical.Clear(); AllLangsVisual.Clear(); VisualStringCache.Clear(); NeedsSave = true; }
public static string GetLocString(string key, string defaultValue) { string result = defaultValue; if (!string.IsNullOrEmpty(CurrentLanguage) && AllLangsVisual.ContainsKey(CurrentLanguage)) { AllLangsVisual[CurrentLanguage].TryGetValue(key, out result); } return(result); }
public static List <string> GetLangKeys() { List <string> keys = new List <string>(); if (!string.IsNullOrEmpty(CurrentLanguage) && AllLangsVisual.ContainsKey(CurrentLanguage)) { keys = AllLangsVisual[CurrentLanguage].Keys.ToList(); } return(keys); }
public static void AddNewLanguage(string name) { LELangDict newLang = new LELangDict(); LELangDict newVisLang = new LELangDict(); MasterKeys.ForEach(masterKey => { newLang.Add(masterKey, string.Empty); newVisLang.Add(Logical2Visual(masterKey), string.Empty); }); AllLangsLogical.Add(name, newLang); AllLangsVisual.Add(name, newVisLang); NeedsSave = true; }
public static void UpdateString(string lang, string key, string value) { string visKey = GetPresentationFromCache(key); string visValue = Logical2Visual(value); Dbg.Assert(AllLangsVisual.ContainsKey(lang)); Dbg.Assert(AllLangsVisual[lang].ContainsKey(visKey)); Dbg.Assert(AllLangsLogical.ContainsKey(lang)); Dbg.Assert(AllLangsLogical[lang].ContainsKey(key)); AllLangsVisual[lang][visKey] = visValue; AllLangsLogical[lang][key] = value; NeedsSave = true; }
static void RebuildVisualTables() { string visKey; string visValue; AllLangsVisual.Clear(); foreach (var langKey in AllLangsLogical.Keys) { LELangDict visLang = new LELangDict(); var string_table = AllLangsLogical[langKey]; foreach (var kvp in string_table) { visKey = Logical2Visual(kvp.Key); visValue = Logical2Visual(kvp.Value); visLang.Add(visKey, visValue); } AllLangsVisual.Add(langKey, visLang); } }