using System; using System.Collections.Generic; using System.IO; using UnityEngine; //using Newtonsoft.Json; using System.Collections; using UnityEngine.Networking; public static class LanguageManager { private static string language = "ua"; public static string Language => language; public static string FilePath => @$"{Application.streamingAssetsPath}/Languages/{language}.json"; private static Dictionary dictionary; static LanguageManager() { SetLanguage(language); } public static void Initialize() { } private static Dictionary GetLanDictionary(string langauge) { if (Application.platform == RuntimePlatform.Android) { return null; //AndroidFileReader.Read(FilePath, () => //{ // //return JsonConvert.DeserializeObject>(AndroidFileReader.Json); //}); } else { if (File.Exists(FilePath)) { using (StreamReader reader = new StreamReader(FilePath)) { string json = reader.ReadToEnd(); return null;//JsonConvert.DeserializeObject>(json); } } else { Debug.Log("Language Get failed "); return null; } } } public static void SetLanguage(string language) { LanguageManager.language = language; dictionary = GetLanDictionary(language); } public static string GetString(string str) { if (dictionary == null) return str; dictionary.TryGetValue(str, out string value); return value ?? str; } }