Ejemplo n.º 1
0
        public IActionResult CreateOrEdit([FromBody] JsonData jsonData)
        {
            JsonResultHelper    result = new JsonResultHelper();
            CustomLocalizeModel model  = jsonData.model;

            _stringLocalizer.AddOrUpdateLocalize(model);
            result.success = true;
            return(Json(result));
        }
Ejemplo n.º 2
0
        public void AddOrUpdateLocalize(CustomLocalizeModel entity)
        {
            string json    = File.ReadAllText(@"Helper/Localization/localization.json");
            bool   isFound = localization.Where(s => s.Key.ToLower().Contains(entity.Resource.ToLower())).Count() > 0;

            if (isFound)
            {
                localization.Remove(localization.Where(s => s.Key.ToLower().Contains(entity.Resource.ToLower())).FirstOrDefault());
            }

            localization.Add(new JsonLocalization()
            {
                LocalizedValue = new Dictionary <string, string>()
                {
                    { "ar-AE", entity.Arabic }, { "en-US", entity.English },
                },
                Key = entity.Resource
            });
            string output = JsonConvert.SerializeObject(localization, Formatting.Indented);

            File.WriteAllText(@"Helper/Localization/localization.json", output);
        }