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.
|
|
using Newtonsoft.Json; using System.Collections.Generic; using System.Configuration; using System.IO;
namespace Common.Language { /// <summary>
/// </summary>
public static class Languages { /// <summary>
/// </summary>
/// <param name="key"></param>
/// <param name="lang"></param>
/// <returns></returns>
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<Dictionary<string, string>>(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<Dictionary<string, string>>(text); dic.TryGetValue(key, out msg); return msg; } return key; } } }
|