public string GetTerm(string code) { TermData.Terms term = this.transform.GetComponent <Loader>().termData; int languageIndex = term.languageIndicies.Find(n => n.key == language).value; if (!term.termTranslations.Exists(n => n.key == code)) { Debug.LogError("Code: " + code + " not finded in database"); return(code); } string[] translations = term.termTranslations.Find(n => n.key == code).value; if (translations.Length == 0) { Debug.LogError("Code: " + code + " don't have translations"); return(code); } return(translations[languageIndex - 1]); }
public IEnumerator ProcessData(string data, System.Action <string> onCompleted) { yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); yield return(new WaitForEndOfFrame()); termData = new TermData.Terms(); // Line level int currLineIndex = 0; bool inQuote = false; int linesSinceUpdate = 0; int kLinesBetweenUpdate = 15; // Entry level string currEntry = ""; int currCharIndex = 0; bool currEntryContainedQuote = false; List <string> currLineEntries = new List <string>(); // "\r\n" means end of line and should be only occurence of '\r' (unless on macOS/iOS in which case lines ends with just \n) char lineEnding = Application.platform == RuntimePlatform.IPhonePlayer ? '\n' : '\r'; int lineEndingLength = Application.platform == RuntimePlatform.IPhonePlayer ? 1 : 2; data += lineEnding; while (currCharIndex < data.Length) { if (!inQuote && (data[currCharIndex] == lineEnding)) { // Skip the line ending currCharIndex += lineEndingLength; // Wrap up the last entry // If we were in a quote, trim bordering quotation marks if (currEntryContainedQuote) { currEntry = currEntry.Substring(1, currEntry.Length - 2); } currLineEntries.Add(currEntry); currEntry = ""; currEntryContainedQuote = false; // Line ended ProcessLineFromCSV(currLineEntries, currLineIndex); currLineIndex++; currLineEntries = new List <string>(); linesSinceUpdate++; if (linesSinceUpdate > kLinesBetweenUpdate) { linesSinceUpdate = 0; yield return(new WaitForEndOfFrame()); } } else { if (data[currCharIndex] == '"') { inQuote = !inQuote; currEntryContainedQuote = true; } // Entry level stuff { if (data[currCharIndex] == ',') { if (inQuote) { currEntry += data[currCharIndex]; } else { // If we were in a quote, trim bordering quotation marks if (currEntryContainedQuote) { currEntry = currEntry.Substring(1, currEntry.Length - 2); } currLineEntries.Add(currEntry); currEntry = ""; currEntryContainedQuote = false; } } else { currEntry += data[currCharIndex]; } } currCharIndex++; } progress = (int)((float)currCharIndex / data.Length * 100.0f); } onCompleted(null); }
private void ProcessLocalData() { termData = SaveAndLoad.DeserializeObject <TermData.Terms>(SaveAndLoad.Load("Terms")); afterDownloadSetupTexts?.Invoke(); Debug.Log("Old version local loaded"); }