using Newtonsoft.Json; using System.Collections.Generic; using System.Configuration; using System.IO; namespace Common.Language { /// /// public static class Languages { /// /// /// /// /// public static string GetMessage(string key, string lang) { string text = null; var path = (ConfigurationManager.AppSettings["PushNotification_Resource"]).ToString(); //if (string.IsNullOrEmpty(lang)) //{ // text = File.ReadAllText(path+"PushNotification_en.json"); //} //else { // text = File.ReadAllText(path+"PushNotification_"+lang+ ".json"); //} text = File.ReadAllText(path + "PushNotification_en.json"); if (!string.IsNullOrEmpty(text)) { var msg = key; var dic = JsonConvert.DeserializeObject>(text); dic.TryGetValue(key, out msg); return msg; } return key; } public static string GetTitle(string key, string lang) { string text = null; var path = (ConfigurationManager.AppSettings["PushNotification_Resource"]).ToString(); //if (string.IsNullOrEmpty(lang)) //{ // text = File.ReadAllText(path + "PushNotification_Title_en.json"); //} //else //{ // text = File.ReadAllText(path + "PushNotification_Title_" + lang + ".json"); //} text = File.ReadAllText(path + "PushNotification_Title_en.json"); if (!string.IsNullOrEmpty(text)) { var msg = key; var dic = JsonConvert.DeserializeObject>(text); dic.TryGetValue(key, out msg); return msg; } return key; } } }