public string getString(string file, string label) { //Creates a dictionary for the current file Dictionary <string, string> table; //If the dictionary has already been read in, get it from the tables dictionary if (tables.ContainsKey(file)) { table = tables [file]; } //If it is a new dictionary, parses it using my super cool parser //Adds it to the dictionary of dictionaries else { table = RaphaelsSuperCoolJsonParser.toStringDictionary("Assets/Resources/Local/" + file + ".txt"); tables.Add(file, table); } //If the label is not in the dictionary, doesn't chanege anything if (!table.ContainsKey(label + language)) { //Debug.LogWarning("File " + file + " does not contain " + label + language); return(label); } if (string.IsNullOrEmpty(table [label + language].ToString())) { return(null); } return(table [label + language].ToString()); }
public string getString(string file, string label, string englishText) { Dictionary <string, string> table; //If the dictionary has already been read in, get it from the tables dictionary if (tables.ContainsKey(file)) { table = tables [file]; } //If it is a new dictionary, parses it using my super cool parser //Adds it to the dictionary of dictionaries else { table = RaphaelsSuperCoolJsonParser.toStringDictionary("Assets/Resources/Local/" + file + ".txt"); tables.Add(file, table); } //bool for whether or not the table was changed bool add = false; //If the table does not contain the key, adds the key/object pair if (!table.ContainsKey(label + language)) { table.Add(label + language, englishText); add = true; } //If the table contains the key, but the string it contains is different from englishText //Changes the string at key to englishText else if (!(table [label + language].ToString().Equals(englishText))) { table [label + "_en"] = englishText; table [label + "_sp"] = ""; table [label + "_fr"] = ""; table [label + "_it"] = ""; table [label + "_jp"] = ""; add = true; } //If the table was changed if (add) { //Writes a new json file string newJson = "{\n"; foreach (string s in table.Keys) { newJson += "\t\"" + s + "\": \"" + table [s] + "\",\n"; } newJson = newJson.Remove(newJson.Length - 2) + "\n}"; //Writes the new one File.WriteAllText("Assets/Resources/Local/Source/" + file + ".txt", newJson); } return(table [label + language].ToString()); }