示例#1
0
 public List <ResourcesFormModel> GetListLang(string lang)
 {
     #region [Get Language and set Cookies]
     string     culture = CultureHelper.GetImplementedCulture(lang);
     HttpCookie cookie  = Request.Cookies["_culture"];
     if (cookie != null)
     {
         cookie.Value = culture;   // update cookie value
     }
     else
     {
         cookie         = new HttpCookie("_culture");
         cookie.Value   = culture;
         cookie.Expires = DateTime.Now.AddYears(1);
     }
     Response.Cookies.Add(cookie);
     #endregion
     ResourceSet resourceSet = Resources.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
     //ResXResourceReader read = new ResXResourceReader(AppDomain.CurrentDomain.BaseDirectory + "Resources.en.resx");
     List <ResourcesFormModel> listResource = new List <ResourcesFormModel>();
     foreach (DictionaryEntry entry in resourceSet)
     {
         ResourcesFormModel item = new ResourcesFormModel();
         item.Name  = entry.Key.ToString();
         item.Value = entry.Value.ToString();
         listResource.Add(item);
     }
     //resourceSet.Dispose();
     return(listResource);
 }
示例#2
0
        public ActionResult ViewVietNam()
        {
            List <ResourcesFormModel> listResource;;
            XmlDocument loResource = new XmlDocument();

            loResource.Load(Server.MapPath("~/Resources.vi.resx"));

            XmlNodeList loRoot = loResource.SelectNodes(
                string.Format("root/data"));

            foreach (XmlNode item in loRoot)
            {
                ResourcesFormModel obj = new ResourcesFormModel();
                obj.Name  = item.InnerText.ToString();
                obj.Value = item.SelectSingleNode(string.Format("data/value")).Value;
                obj.Value = item.InnerXml;
            }
            return(View());
        }
示例#3
0
        public ActionResult Create(ResourcesFormModel obj)
        {
            string key   = obj.Name;
            string value = obj.Value;

            XmlDocument loResource = new XmlDocument();

            loResource.Load(Server.MapPath("~/Resources.vi.resx"));

            XmlNode loRoot = loResource.SelectSingleNode(
                string.Format("root/data[@name='{0}']/value", key));

            if (loRoot != null)
            {
                loRoot.InnerText = value;
                loResource.Save(Server.MapPath("~/Resources.vi.resx"));
            }
            clearCookie();
            return(RedirectToAction("Index"));
        }