using System.Collections; using System.Collections.Generic; using UnityEngine; public delegate string RequestLanguageFind(string type, string idx); public enum TypeLanguage { KOR = 0, ENG } [System.Serializable] public class DataLanguage : IData { static public string keyLanguageSelect = "LanguageSelect"; public TypeLanguage typeLanguage = TypeLanguage.KOR; Dictionary> listLanguage; public override void TableLoad() { listLanguage = new Dictionary>(); if (PlayerPrefs.HasKey($"{keyLanguageSelect}")) typeLanguage = Util.EnumUtil.Parse(PlayerPrefs.GetString($"{keyLanguageSelect}")); else { switch(Application.systemLanguage) { case SystemLanguage.Korean: typeLanguage = TypeLanguage.KOR; break; default: typeLanguage = TypeLanguage.ENG; break; } PlayerPrefs.SetString($"{keyLanguageSelect}", $"{typeLanguage}"); } string[] strLine = FileLoadWithLineSplit(path == string.Empty ? "CSV/Language" : path); string[] spl; Dictionary listValue = null; for (int i = 1; i < strLine.Length; i++) { if (1 < strLine[i].Length) { spl = strLine[i].Split(','); if (!listLanguage.ContainsKey(spl[0])) listLanguage.Add(spl[0], new Dictionary()); listValue = listLanguage[spl[0]]; listValue.Add(spl[1], spl[(int)typeLanguage + 2]); } } } public override void LoadedCheck() { if (listLanguage == null) TableLoad(); } public string Search(string type, string idx) { LoadedCheck(); if (listLanguage.ContainsKey(type)) { if (listLanguage[type].ContainsKey(idx)) { string str = listLanguage[type][idx].Replace('^', ',').Replace('|', '\n'); return str; } } return $"ERR - {type}, {idx}"; } }