static public int IsLineBreak_s(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif System.String a1; checkType(l, 1, out a1); var ret = LocalizationImporter.IsLineBreak(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
public static string Get(string key, Language language) { var languages = LocalizationImporter.GetLanguages(key); var selected = (int)language; if (languages.Count > 0 && selected >= 0 && selected < languages.Count) { var currentString = languages[selected]; if (string.IsNullOrEmpty(currentString) || LocalizationImporter.IsLineBreak(currentString)) { Debug.LogWarning("Could not find key " + key + " for current language " + language + ". Falling back to " + Instance.fallbackLanguage + " with " + languages[(int)Instance.fallbackLanguage]); selected = (int)Instance.fallbackLanguage; currentString = languages[selected]; } #if ARABSUPPORT_ENABLED if (selected == (int)Language.Arabic) { return(ArabicSupport.ArabicFixer.Fix(currentString, instance.showTashkeel, instance.useHinduNumbers)); } #endif return(currentString); } return(string.Format(KeyNotFound, key)); }
internal List <Language> GetLanguagesInSheets(params LocalizationAsset[] assets) { List <Language> supported = new List <Language>(); supported.AddRange(Localization.Instance.GetField <List <Language>, Localization>("supportedLanguages")); var locTable = new Dictionary <string, List <string> >(); for (int i = 0; i < assets.Length; i++) { var asset = assets[i]; List <List <string> > textData; if (asset.Format == GoogleDriveDownloadFormat.CSV) { textData = CsvReader.Parse(asset.TextAsset.text.Replace("\r\n", "\n")); } else { textData = TsvReader.Parse(asset.TextAsset.text.Replace("\r\n", "\n")); } bool isValid = false; for (int a = 0; a < textData.Count; a++) { List <string> valList = textData[a]; string keyName = valList[0]; if (!string.IsNullOrEmpty(keyName) && !LocalizationImporter.IsLineBreak(keyName) && valList.Count > 1) { if (!isValid && keyName.StartsWith("Polyglot")) { isValid = true; } else if (isValid) { valList.RemoveAt(0); valList.RemoveAt(0); if (locTable.ContainsKey(keyName)) { locTable[keyName] = valList; } else { locTable.Add(keyName, valList); } } } } } ISet <int> validLanguages = new HashSet <int>(); foreach (var value in locTable.Values) { for (int i = 0; i < value.Count; i++) { if (!string.IsNullOrEmpty(value.ElementAtOrDefault(i))) { validLanguages.Add(i); } } } supported.Clear(); for (int i = 0; i < validLanguages.Count; i++) { supported.Add((Language)validLanguages.ElementAt(i)); } return(supported); }