public static string Get(string key, ref bool success) { if (string.IsNullOrEmpty(key)) { return(key); } int length = key.IndexOf("."); if (length < 0) { return(key); } string tableID = key.Substring(0, length); string key1 = key.Substring(length + 1); LocalizedText.TextTable textTable = LocalizedText.FindTable(tableID); if (textTable == null) { textTable = LocalizedText.InternalLoadTable(tableID, (LocalizedText.TextTable)null); if (textTable == null) { return(key); } } string text = textTable.FindText(key1); success = !string.IsNullOrEmpty(text) && !text.Equals(key1); return(text); }
private static LocalizedText.TextTable InternalLoadTable(string language, string tableID, LocalizedText.TextTable overwriteTable = null) { LocalizedText.TextTable textTable; if (overwriteTable == null) { textTable = new LocalizedText.TextTable(tableID); LocalizedText.mTables.Add(textTable); } else { textTable = overwriteTable; textTable.Items.Clear(); } string path = LocalizedText.ComposeTablePath(language, tableID); string s; if (LocalizedText.UseAssetManager) { s = AssetManager.LoadTextData(path); } else { TextAsset textAsset = (TextAsset)Resources.Load <TextAsset>(path); s = !Object.op_Inequality((Object)textAsset, (Object)null) ? (string)null : textAsset.get_text(); } if (s != null) { Debug.LogWarning((object)("SG: Loading text table '" + tableID + "'")); char[] separator = new char[1] { '\t' }; using (StringReader stringReader = new StringReader(s)) { string end = stringReader.ReadToEnd(); char[] chArray = new char[1] { '\n' }; foreach (string str in end.Split(chArray)) { if (!string.IsNullOrEmpty(str) && !str.StartsWith(";")) { string[] strArray = str.Split(separator, 2); if (strArray.Length >= 2 && !string.IsNullOrEmpty(strArray[0]) && !string.IsNullOrEmpty(strArray[1])) { textTable.Items[strArray[0]] = strArray[1].Replace("<br>", "\n"); } } } } } else { Debug.LogError((object)("Failed to load text '" + path + "'")); LocalizedText.mTables.Remove(textTable); } return(textTable); }
public static string[] GetTextIDs(string tableID) { LocalizedText.TextTable table = LocalizedText.FindTable(tableID); if (table != null) { return(new List <string>((IEnumerable <string>)table.Items.Keys).ToArray()); } return(new string[0]); }
public static void LoadTable(string tableID, bool forceReload = false) { LocalizedText.TextTable overwriteTable = LocalizedText.FindTable(tableID); if (overwriteTable == null || forceReload) { overwriteTable = LocalizedText.InternalLoadTable(tableID, overwriteTable); } overwriteTable.AutoUnload = false; }
public static void UnloadTable(string tableID) { LocalizedText.TextTable table = LocalizedText.FindTable(tableID); if (table == null) { return; } LocalizedText.mTables.Remove(table); }