Super Knight : Enter the Dungeon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

75 lines
2.2 KiB

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<string, Dictionary<string, string>> listLanguage;
public override void TableLoad()
{
listLanguage = new Dictionary<string, Dictionary<string, string>>();
if (PlayerPrefs.HasKey($"{keyLanguageSelect}"))
typeLanguage = Util.EnumUtil<TypeLanguage>.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<string, string> 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<string, string>());
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}";
}
}